-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Open
Description
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
Labels
No labels