Dashboard
LC #486
Predict the Winner
Pattern · ?
Problem
Two players take turns picking from either end of an array. Return true if player 1 can secure a score >= player 2.
Constraints
- 1 ≤ nums.length ≤ 20
- 0 ≤ nums[i] ≤ 10⁷
Example
- Input
- nums = [1, 5, 2]
- Output
- false
- Why
- P1 takes 1. P2 takes 5. P1 takes 2. Score: P1=3, P2=5. P1 loses.
Spot the pattern
Which pattern cracks it?
Hints
One at a time