All Patterns
Pattern 21
Game Theory & Minimax
Solve two-player zero-sum games where both players play optimally. Generally solved by exploring all future game states using DP or recognizing a mathematical pattern.
Time
O(n²) or O(1)
Space
O(n²) or O(1)
Recognize it when
- Two players taking turns optimally
- "Predict the winner" or "Can player 1 win?"
- Game state reduces on every turn
Progress0/3
0 solved0 attempted
Questions — ordered by difficulty
#292Easy
Nim Game
You play Nim with your friend. There are n stones. You can remove 1, 2, or 3 stones. Given n, determine if you can win assuming both play optimally.
mathgame-theorybrainteaser
#486Medium
Predict the Winner
Two players take turns picking from either end of an array. Return true if player 1 can secure a score >= player 2.
arraydynamic-programmingmath
#877Medium
Stone Game
Similar to Predict the Winner, but with an even number of piles and odd total number of stones. Determine if player 1 can win.
arraydynamic-programmingmath