Leetcode # 203. Remove Linked List Elements
https://leetcode.com/problems/remove-linked-list-elements/ Solution 1 class Solution: def removeElements(self, head: Optional[ListNode], val: int) -> Optional[ListNode]: new_head = head while new_h ...
https://leetcode.com/problems/remove-linked-list-elements/ Solution 1 class Solution: def removeElements(self, head: Optional[ListNode], val: int) -> Optional[ListNode]: new_head = head while new_h ...
https://leetcode.com/problems/linked-list-cycle/ Solution Time Complexity: O(len(linked_list)) Space Complexity: O(1) (The input and output generally do not count towards the space complexity.) class ...
https://leetcode.com/problems/binary-tree-level-order-traversal/ Solution Time Complexity: O(len(tree)) Space Complexity: O(len(tree)) (The input and output generally do not count towards the space co ...
for e in lst[::-1]
https://leetcode.com/problems/n-ary-tree-preorder-traversal/ Solution Time Complexity: O(len(tree)) Space Complexity: O(len(tree)) (The input and output generally do not count towards the space comple ...
BFS 和 DFS 為用以在 tree 中搜尋特定 node 的演算法 Breadth-First Search 廣度優先搜尋 Depth-First Search 深度優先搜尋 相關文章:Binary Tree 二元樹 Iterative Implementation BFS:使用 Queue Template queue = collections.deque([root]) w ...
https://leetcode.com/problems/valid-anagram/ Solution Time Complexity: O(max(len(s), len(t))) Space Complexity: O(max(len(s), len(t))) (The input and output generally do not count towards the space co ...
https://leetcode.com/problems/sort-characters-by-frequency/ Solution Time Complexity: O(len(s)) Space Complexity: O(len(s)) (The input and output generally do not count towards the space complexity.) ...
Asymptotic notations are the mathematical notations that describes the limiting behavior of a function when the argument tends towards a particular value or infinity. O(Big O) Notation \begin{align} & ...
全等於 同餘 $$ a \equiv b \ (mod m) \quad 即 \quad a \ \% \ m == b \ \% \ m $$