Prefix Sum
- 2023.08.29
- Algorithm Prefix Sum
Definition Prefix Sum The sums of prefixes (running totals). $$ y_i = \sum^i_{k = 0}{x_k} $$ 前 i 個 xk 的總和 Prefix ex: breakfast bre 是 breakfast 的 prefix 相關例題 不用確實計算 Prefix Sum 的例子 Leetcode # 2483. Mini ...
Definition Prefix Sum The sums of prefixes (running totals). $$ y_i = \sum^i_{k = 0}{x_k} $$ 前 i 個 xk 的總和 Prefix ex: breakfast bre 是 breakfast 的 prefix 相關例題 不用確實計算 Prefix Sum 的例子 Leetcode # 2483. Mini ...
Problem https://leetcode.com/problems/maximum-average-subarray-i Solution Time Complexity: O(len(nums)) Space Complexity: O(1) (The input and output generally do not count towards the space complexity ...
發聲練習 呼氣練習 肌纖維 紅肌 Red Muscle|慢縮肌 速筋 Slow Twitch|Type I 白肌 White Muscle|快縮肌 遅筋 Fast Twitch | Type II 練習方法 訓練快縮肌的呼氣練習 ha! 30秒 ha~~~ * ha! ha! ha~~~ 注意點: 快又強,直衝腦門 ha 的瞬間,腹壁內縮(橫隔膜放鬆) 再慢慢張開腹部 鄂部保持放鬆 訓練慢縮肌的呼 ...
\begin{align} & \mathop{\text{C’est}}^{\text{sɛ}} \ \mathop{\text{une}}^{\text{ty}} \ \mathop{\text{histoire}}^{\text{nistwaʀ}} \ \mathop{\text{qui}}^{\text{ki}} \ \mathop{\text{a}}^{\text{a ...
Value Types & Reference Types Value Types bool, int, float, char … Reference Types Array, String, class… Default Value bool false char ‘\0’ numeric type 0 reference type nu ...
Problem len(s3) = len(s1) + len(s2) set(s3) = set(s1) | set(s2) Solution: Backtracking + Memoization 重複子問題的例 s1: “aabcc” s2: “dbbca” s3: “aadbbbaccc” s1: “aa ...
Problem https://leetcode.com/problems/candy-crush Solution one_turn() := find() + crush() + drop() m, n := len(board), len(board[0]) Time Complexity: O(m * n) Space Complexity: O(1) (The input and out ...
Problem https://leetcode.com/problems/text-justification Solution Time Complexity: O(len(words)) Space Complexity: O(1) (The input and output generally do not count towards the space complexity.) clas ...
Problem https://leetcode.com/problems/reverse-string Solution Time Complexity: O(n) Space Complexity: O(1) (The input and output generally do not count towards the space complexity.) class Solution: d ...
Problem https://leetcode.com/problems/reorganize-string n := len(s) k := len(set(s)) find s’ := s'[i] != s[i + 1], i = 0, 1, 2, …, n – 1 Solution Time Complexity: O(n + k * log(k)) ...