LeetCode

12. Integer to Roman

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

1446. Consecutive Characters

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

1004. Max Consecutive Ones III

1004. Max Consecutive Ones III class Solution: def longestOnes(self,

904. Fruit Into Baskets

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

1492. The kth Factor of n

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

930. Binary Subarrays With Sum

930. Binary Subarrays With Sum

700. Search in a Binary Search Tree

700. Search in a Binary Search Tree 如果說題目只是問「樹」中是否存在一個節點有某個值,

450. Delete Node in a BST

450. Delete Node in a BST 這個題目給定的條件可以很簡單:給定一個數值,要我們在二元搜尋樹中找到哪個節點的數值等於此值,並且刪掉他。

323. Number of Connected Components in an Undirected Graph

可以繼承 547. Number of Provinces 的做法,先轉換給定的 edges 成一個矩陣。 class

116. Populating Next Right Pointers in Each Node

116. Populating Next Right Pointers in Each Node 這一題要考的點是對進行 BFS