Tree

450. Delete Node in a BST

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

700. Search in a Binary Search Tree

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

116. Populating Next Right Pointers in Each Node

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

117. Populating Next Right Pointers in Each Node II

117. Populating Next Right Pointers in Each Node II "

102. Binary Tree Level Order Traversal

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

323. Number of Connected Components in an Undirected Graph

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

652. Find Duplicate Subtrees

652. Find Duplicate Subtrees 建議先做過 536. Construct Binary Tree from

279. Perfect Squares

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

145. Binary Tree Postorder Traversal

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

111. Minimum Depth of Binary Tree

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