Skip to content

Bug Report for stone-game #4652

@Guohuan-Feng

Description

@Guohuan-Feng

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy