Remove Node in Binary Search Tree
Last updated
Last updated
"""
Definition of TreeNode:
class TreeNode:
def __init__(self, val):
self.val = val
self.left, self.right = None, None
"""
class Solution:
"""
@param root: The root of the binary search tree.
@param value: Remove the node with given value.
@return: The root of the binary search tree after removal.
"""
def removeNode(self, root, value):
# write your code here
if root == None:
return None
if root.val == value:
root = self.removeNode(root.left, value)