LeetCode75-450-Delete-Node-in-BST
🧠 Summary of Thoughts
- Locate key in BST, use the property of BST below:
BST property:
leftNode < root < rightNode- if
key < root.val, then call left tree recursively - if
key > root.val, then call right tree recursively
- if
- If the key node is found, then delete:
- if there is NO left tree, then return the right tree
- if there is NO right tree, then return the left tree
- if left and right tree are exist:
- find the leftmost of the right tree, and use this value to replace the previous node key
✅ Code(Java)
1 | |
LeetCode75-450-Delete-Node-in-BST
https://powersixxx.github.io/leetcode-blog/2026/03/14/LeetCode75-450-Delete-Node-in-BST/