LeetCode

1492. The kth Factor of n

1492. The kth Factor of n 這一個題目可以直接用暴力法來解,搜尋空間為 1 到

102. Binary Tree Level Order Traversal

102. Binary Tree Level Order Traversal BFS # Definition for a

23. Merge k Sorted Lists

23. Merge k Sorted Lists 這一題有多個不同的做法,我喜歡先從已經有的概念來出法,第一個概念是我們已經知道 21. Merge

904. Fruit Into Baskets

904. Fruit Into Baskets class Solution: def totalFruit(self, fruits:

31. Next Permutation

31. Next Permutation 題目是給定一個數字,要使用這個數字有使用到的數字,並透過排列組合,找到下一個排列組合比現在這個數字還大,可是卻是所有可行的排列組合中最小的,如果說現在的這個數字已經是排列組合中最大的數字,那我們就回傳排列組合中最小的數字。

394. Decode String

394. Decode String 這一個題目是 Stack 常見的考題做法 1. 如果我們遇到連續的字元,就把「字元」

1004. Max Consecutive Ones III

1004. Max Consecutive Ones III 這個題目是基於題目 485. Max Consecutive Ones

1446. Consecutive Characters

1446. Consecutive Characters class Solution: def maxPower(self, s: str)

12. Integer to Roman

12. Integer to Roman 直接把規則寫出來 class Solution: def intToRoman(self,

862. Shortest Subarray with Sum at Least K

862. Shortest Subarray with Sum at Least K 這個題目其實很近似於雙指針的問題,我在看完題目後的第一個想法是,