Leetcode # 101. Symmetric Tree
https://leetcode.com/problems/symmetric-tree/ Solution Time Complexity: O(len(tree)) Space Complexity: O(len(tree)) (The input and output generally do not count towards the space complexity.) class So ...
https://leetcode.com/problems/symmetric-tree/ Solution Time Complexity: O(len(tree)) Space Complexity: O(len(tree)) (The input and output generally do not count towards the space complexity.) class So ...
https://leetcode.com/problems/path-sum/ Solution Return True if the tree has a root-to-leaf path Time Complexity: O(len(tree)) Space Complexity: O(len(tree)) (The input and output generally do not cou ...
https://leetcode.com/problems/number-of-connected-components-in-an-undirected-graph Solution: Disjoint Set Union (DSU) Time Complexity: O() Space Complexity: O() (The input and output generally do not ...
https://leetcode.com/problems/number-of-islands/ Solution: Disjoint Set Union (DSU) Time Complexity: O(len(grid) * len(grid[0])) Space Complexity: O(len(grid) * len(grid[0])) (The input and output gen ...
https://leetcode.com/problems/leaf-similar-trees/ Solution Time Complexity: O(len(tree1 + tree2)) Space Complexity: O(len(tree1 + tree2)) (The input and output generally do not count towards the space ...
NAME := expr Assign to variables within an expression using the notation. 使用例 if Statement sex = 0 if sex == 0: print("boy") ⇒ if (sex := 0) == 0: print("boy") while Statement 例1:讀取檔案 file = open("... ...
Conditionals / Conditional expressions a is None / a is not None a == None / a != None not a (not 0 為 True) Python 中視作 False 的物件 None, False 0 (), [], {}, set(), range(0) In if/while statement if a: ...
https://leetcode.com/problems/validate-binary-search-tree/ Solution Time Complexity: O(len(BST)) Space Complexity: O(len(BST)) (The input and output generally do not count towards the space complexity ...
https://leetcode.com/problems/valid-parentheses/ Solution Time Complexity: O(len(s)) Space Complexity: O(len(s)) (The input and output generally do not count towards the space complexity.) class Solut ...
https://leetcode.com/problems/range-sum-of-bst/ Solution Time Complexity: O(len(tree)) Space Complexity: O(len(tree)) (The input and output generally do not count towards the space complexity.) class ...