Skip to content

Bug Report for delete-node-in-a-bst #4713

@cynthiacai10

Description

@cynthiacai10

Bug Report for https://neetcode.io/problems/delete-node-in-a-bst

For test case: root=[5,3,6,2,4,null,7], key=5
My output: [4,3,6,2,null,null,7]
Expected output: [6,3,7,2,4]

My solution fails this test case because the platform expects the node to be replaced with the inorder successor (smallest value in the right subtree).

However, my implementation uses the inorder predecessor (largest value in the left subtree).

Both approaches are valid in BST deletion — the resulting tree structure can differ but remains a correct BST. Furthermore, my code is accepted at leetcode. Therefore, I believe neetcode currently only accepts one valid variant, while multiple correct outputs should be allowed.

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