1. Description
Alice and Bob alternate taking stones from a pile of n stones, with Alice moving first. Her first move must remove exactly 10 stones.
Every later move must remove exactly one fewer stone than the previous move. A player who cannot remove the required number loses.
Return true if Alice wins, or false if Bob wins.
2. Example
Example 1
Input: n = 12
Output: true
Explanation: Alice takes 10 stones, leaving 2. Bob needs to take 9 stones but cannot, so Alice wins.
Example 2
Input: n = 1
Output: false
Explanation: Alice cannot take the required 10 stones on her first turn, so she loses.
3. Constraints
- 1 <= n <= 50
4. Solutions
Simulation
Time complexity: O(1)
Space complexity: O(1)
| |