Setting Up RUST Server on Ubuntu 22.04 2023/10/18 創立並 CD 至 {RustServer} 資料夾 照著 LinuxGSM_: RUST Dependencies Install CD 至 {RustServer}/lgsm/config-lgsm/rustserver cp _default.cfg rustserver.cfg 編輯 rust ...
bisect 回傳插入x的index ( O(long(n)) ),保持a的排序 (a是個已排序 list ) 若x已存在a中則index會在a中的所有x的右/左邊 bisect.bisect(a, x[, lo=0, hi=len(a), *, key=None]) ≡ bisect.bisect_right(a, x[, lo=0, hi=len(a), *, key=None]) ...
Problem https://leetcode.com/problems/minimum-array-length-after-pair-removals Testcases # Input Expected 1 [1,1] 2 2 [1,2] 0 3 [1,2,2] 1 4 [1,1,2,3,4,4] 0 Failed Solution: Greedy [Wrong Answer 338 ...
Shallow copy: To construct a new compound object and then (to the extent possible) insert references into it to the objects found in the original. Deep copy: To construct a new compound object and the ...
Problem https://leetcode.com/problems/find-a-corresponding-node-of-a-binary-tree-in-a-clone-of-that-tree Solution: DFS n := number of nodes in the original tree Time Complexity: O(n) Space Complexity: ...
Problem https://leetcode.com/problems/kth-ancestor-of-a-tree-node First Solution: Binary Lifting [Time Limit Exceeded 8 / 17 testcases passed] Time Complexity: O(n ** 2) __init__(): worst case – ...
Problem https://leetcode.com/contest/weekly-contest-361/problems/minimum-edge-weight-equilibrium-queries-in-a-tree/ There is an undirected tree with n nodes labeled from 0 to n – 1. You are give ...
sum(1 for ... in ... if ...) or sum(1 if ... else 0 for ... in ...)
Problem https://leetcode.com/contest/weekly-contest-361/problems/count-of-interesting-subarrays/ 相關例題 Leetcode # 974. ⭐️ Subarray Sums Divisible by K Solution: Dynamic Programming [Time Limit Exceeded ...
Problem https://leetcode.com/problems/subarray-sums-divisible-by-k Solution 令 nums[i] = [4, 5, 0, -2, -3, 1], k = 5 能夠被k整除的子字串有: [5], [0], [5, 0], [-2, -3], [0, -2, -3], [5, 0, -2, -3], [4, 5, 0, -2, ...