↓快轉到主要內容

Brainteaser

Math 數學技巧
·5 分鐘
演算法 Math Combinatorics Geometry Brainteaser
組合計數(配對數、切分方式)、第 k 個排列逐位決定、幾何(最近點、餘弦定理、三角不等式)、排序或觀察之後變成公式的題目,以及直式進位、進位制轉換和快速冪
LeetCode 3828: Final Element After Subarray Deletions
·1 分鐘
LeetCode Medium Math Brainteaser Game-Theory Array
LeetCode 3828 解題筆記:Alice 第一步就能只留下頭或尾,所以至少拿到 max(頭, 尾);Bob 每次也能只留下目前的頭或尾,而 Alice 的一次刪除最多改變其中一端,所以答案就是 max(頭, 尾)
LeetCode 2745: Construct the Longest New String
·1 分鐘
LeetCode Medium Dynamic-Programming Math Greedy Brainteaser
LeetCode 2745 解題筆記:AA 和 BB 必須交替出現,最多用 min(x, y) 對,多的那種還能再多放一個;AB 全部都能接上
LeetCode 1025: Divisor Game
·1 分鐘
LeetCode Easy Math Dynamic-Programming Brainteaser Game-Theory
LeetCode 1025 解題筆記:dp[i] = 存在 i 的因數 x 讓 dp[i - x] 是輸;觀察後答案就是 n 是偶數
LeetCode 292: Nim Game
·1 分鐘
LeetCode Easy Math Brainteaser Minimax-Algorithm Game-Theory
LeetCode 292 解題筆記:剩 4 的倍數顆石頭的人必輸,所以 n % 4 != 0 時先手贏