O38
Delete Node in a BST
Problem Statement & Objective
Given a root node of a BST and a key, delete the node with the given key in the BST. Return the root node of the BST after deletion.
Function Signature (Python)
delete_node_in_a_bst(root: list, anahtar: int) -> listInput & Output Contract
Output Rule:Güncellenmiş BST elemanları listesi.
System Constraints
0 <= agac.length <= 1000
-10^4 <= agac[i], anahtar <= 10^4Example Execution Walkthrough
agac = [5, 3, 6, 2, 4, None, 7], anahtar = 3
3 silinir, yerine 4 geçer -> [5, 4, 6, 2, None, None, 7]Example Test Scenarios (3)
Example 1
Input:
[[5,3,6,2,4,null,7],3]Expected Output:
[5,4,6,2,null,null,7]Example 2: Olmayan Düğüm
Input:
[[5,3,6,2,4,null,7],0]Expected Output:
[5,3,6,2,4,null,7]Example 3: Boş Ağaç
Input:
[[],0]Expected Output:
[]