Leetcode # 1615. Maximal Network Rank
https://leetcode.com/problems/maximal-network-rank Solution E := number of edges = len(cities) V := number of vertexes/nodes = len(roads) Time Complexity: O(E + V ** 2) Space Complexity: O(E) (The inp ...
https://leetcode.com/problems/maximal-network-rank Solution E := number of edges = len(cities) V := number of vertexes/nodes = len(roads) Time Complexity: O(E + V ** 2) Space Complexity: O(E) (The inp ...
https://leetcode.com/problems/remove-one-element-to-make-the-array-strictly-increasing Solution n := len(nums) Ni := nums[i] i := [1, n – 1] 「如果我們從 nums 刪除一個節點後,nums 為嚴格遞增」 如果 nums 原本不是嚴格遞增 但符合題 ...
https://leetcode.com/problems/sliding-window-maximum First Solution Time Complexity: O((n – k) * log(k)) Space Complexity: O(k) (The input and output generally do not count towards the space com ...
timeit timeit timeit.timeit( stmt='pass', setup='pass', timer=<default timer>, number=1000000, globals=None ) repeat timeit.repeat( stmt='pass', setup='pass', timer=<default t ...
https://leetcode.com/problems/partition-list Solution ge_cur.next = cur ge_cur = cur → ge_cur = ge_cur.next = cur ⇒ 1. ge_cur ← cur 2. ge_cur.next ≡ cur.next ← cur ⇒ loop ge_cur.next = ge_cur = cur ⇒ ...
Naming grid is a m × n matrix m := len(grid) n := len(grid[0]) $$ grid = \left| \begin{aligned} & a_{0, 0} & \quad & a_{0, 1} & \quad & a_{0, 2} & \quad & … & \qu ...
Naming Convention Python Class and Function/Method (UpperCamelCase) Constant (CAPITALIZED_WITH_UNDERSCORES) Others (lowercase_separated_by_underscores) Underscore Before a Name (name_) Avoid Keyword C ...
https://leetcode.com/problems/the-maze Solution m := len(maze) n := len(maze[0]) Time Complexity: O(m * n) Space Complexity: O(m * n) (The input and output generally do not count towards the space com ...
https://leetcode.com/problems/kth-largest-element-in-an-array Solution n := len(nums) Time Complexity: O(n * log(k)) Space Complexity: O(k) (The input and output generally do not count towards the spa ...
https://leetcode.com/problems/check-if-there-is-a-valid-partition-for-the-array Solution n := len(nums) Time Complexity: O(3 ** n)O(n) (due to memoization) Space Complexity: O(n) (The input and output ...