↓Skip to main content

Game-Theory

LeetCode 3828: Final Element After Subarray Deletions
·2 mins
LeetCode Medium Math Brainteaser Game-Theory Array
LeetCode 3828 note: Alice can leave only the first or last element on her first move, guaranteeing max(first, last); Bob can likewise keep only an end, and one deletion changes at most one end, so the answer is max(first, last)
LeetCode 3627: Maximum Median Sum of Subsequences of Size 3
·2 mins
LeetCode Medium Math Greedy Sorting Game-Theory Array
LeetCode 3627 note: after sorting, each group takes the two largest and the smallest, with the second largest as the median; the answer takes every other value from the end, n / 3 of them
LeetCode 1025: Divisor Game
·2 mins
LeetCode Easy Math Dynamic-Programming Brainteaser Game-Theory
LeetCode 1025 note: dp[i] holds when some divisor x of i makes dp[i - x] a loss; observing the pattern, the answer is simply whether n is even
LeetCode 292: Nim Game
·1 min
LeetCode Easy Math Brainteaser Minimax-Algorithm Game-Theory
LeetCode 292 note: whoever faces a multiple of 4 stones loses, so the first player wins when n % 4 != 0