1510. Stone Game IV
https://leetcode.com/problems/stone-game-iv
Description
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.
Example 1:
Example 2:
Example 3:
Example 4:
Example 5:
Constraints:
1 <= n <= 10^5
ac
Previous1509. Minimum Difference Between Largest and Smallest Value in Three MovesNext1511. Customer Order Frequency
Last updated
Was this helpful?