-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Description
Bug Report for https://neetcode.io/problems/stone-game
Please describe the bug below and include any steps to reproduce the bug or screenshots if possible.
Title: Stone Game: wrong expected output for test case [100,200,300,400,101] Description: On https://neetcode.io/problems/stone-game the built-in test case piles = [100,200,300,400,101] shows Expected output: true, but that is mathematically incorrect. For odd-length arrays the first player cannot force parity control; with ends at indices 0 and 4 (both even), the second player can always take all odd-index piles (1 and 3). Sum(odd indices)=200+400=600, Sum(even indices)=100+300+101=501, so second player wins by 99. A standard DP formulation dp[i][j]=max(piles[i]-dp[i+1][j], piles[j]-dp[i][j-1]) yields dp[0][4]=-99, confirming first player loses. Therefore the correct expected output for this case is false. Environment: Python 3; any correct DP or greedy-parity analysis gives the same result.