P14510 [GeeksforGeeks] Delete nodes greater than k
普及
题目描述

Given a BST and a value k, the task is to delete the nodes having values greater than or equal to k.
Example 1:
Input:
4
/ \
1 9
k = 2
Output:
1
Your Task:
The task is to complete the function deleteNode() which takes root, k as the argument, and returns the root of tree after deleting values greater than or equal to k. The driver code will print the inorder traversal of the updated tree in output itself.
Expected Time Complexity: O(Size of tree)
Expected Auxiliary Space: O(1).
Constraints:
1 <= T <= 100
1 <= N <= 10^{3}
1 <= A[] <= 10^{3}
1 <= k <= N

输入格式

见题面

输出格式

见题面

样例输入
4 / \ 1 9 k = 2
样例输出
1