You and a friend take turns removing 1 to 3 stones from a single heap, and you move first. Whoever takes the last stone wins. Assuming both of you play optimally, return true if you can win with n stones on the heap.
You and a friend take turns removing 1 to 3 stones from a single heap, and you move first. Whoever takes the last stone wins. Assuming both of you play optimally, return true if you can win with n stones on the heap.
Example 1:
Input: {"n":4}
Output: false
Constraints:
1≤n≤231−1
Test Cases
Input (Stdin)
Expected Output (Stdout)
Execution Result
Run code to see results.
Input
arr ={"n":4}
4 stones on the heap, you move first. Solve small heaps first to see who wins each one.