Practice Stone Game IV
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Problem Statement
Alice and Bob take turns playing a game, with Alice starting first. Initially, there are n stones in a pile. On each player's turn, that player makes a move consisting of removing any non-zero square number of stones in the pile. Also, if a player cannot make a move, he/she loses the game. Given a positive integer n, return true if and only if Alice wins the game otherwise return false, assuming both players play optimally.
Source: Stone Game IV on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
n = 1
true
# Example 2
n = 2
false
# Example 3
n = 4
true
Constraints
Related LeetCode Problems
Practice more problems similar to Stone Game IV.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.