Delete nodes greater than k
Submissions: 4260   Accuracy:

47%

  Difficulty: Easy   Marks: 2

Given a BST and a value x, the task is to delete the nodes having values greater than or equal to x.

Input Format:
The first line of input contains an integer T denoting the no of test cases. Then T test cases follow. The first line of each test case consists of an integer N. Then in the next line are N space separated values of the BST nodes. In the next line is an integer x representing the value of the node in the BST.

Output Format:
For each test case, in a new line, print the inorder traversal after deletions.

Constraints:
1 <= T <= 100
1 <= N <= 103
1 <= A[] <= 103
1 <= x <= N

Example:
Input:

2
7
20 8 22 4 12 10 14
8
7
20 8 22 4 12 10 14
10
Output:
4
4 8

** For More Input/Output Examples Use 'Expected Output' option **

Contributor: Harshit Sidhwa,Saksham Raj Seth
Author: Shubham Joshi 1


Need help with your code? Please use ide.geeksforgeeks.org, generate link and share the link here.

to report an issue on this page.