LeetCode

111. Minimum Depth of Binary Tree

111. Minimum Depth of Binary Tree DFS # Definition for a

145. Binary Tree Postorder Traversal

145. Binary Tree Postorder Traversal # Definition for a binary tree

279. Perfect Squares

279. Perfect Squares 這一個題目是一個非常彈性的題目,題目的問題非常簡單,找到最少個完全平方數其總和為題目給定的 n 。 首先第一個要先想到的是,我們要找的完全平方數,一定是比這個數還來的小,

994. Rotting Oranges

994. Rotting Oranges 題目的說明 題目有說明的有,腐爛的橘子會影響旁邊的好橘子,好橘子會爛掉,如果好橘子相連的好橘子有和爛橘子相連,過了一段時間後也會爛掉,如果有橘子沒有和任何的爛橘子相鄰就不會壞掉。

648. Replace Words

648. Replace Words 這一題就屬於一開始看題目比較不容易看出來要是用 Trie ,題目中的一個小提示是最後我們要輸出的字串,是要輸出的是每個單字的 prefix ,看到要找 prefix

428. Serialize and Deserialize N-ary Tree

428. Serialize and Deserialize N-ary Tree

572. Subtree of Another Tree

# Definition for a binary tree node. # class TreeNode: # def __init_

589. N-ary Tree Preorder Traversal

589. N-ary Tree Preorder Traversal """ # Definition for

606. Construct String from Binary Tree

606. Construct String from Binary Tree # Definition for a binary

105. Construct Binary Tree from Preorder and Inorder Traversal

105. Construct Binary Tree from Preorder and Inorder Traversal 題目給出前序遍歷以及中序遍歷的順序,