11626 - BST - Remove   

Description

Giving you a Binary Search Tree (BST) and a list of numbers, you need to remove all the nodes in the BST whose value appears in the list.

Input

The first line contains an integer N (N < 500), represents the number of nodes in the BST.

The second line contains N integers, construct a BST in order of appearance (treat the first value as root).

The third lines contains an array of integers, remove all of them in BST if it existed.

for example: The BST constructed from sample input would be like : 

Output

Output the in-order traversal of the BST.

Note: The corret result should be in ascending order .

Sample Input  Download

Sample Output  Download

Partial Judge Code

11626.c

Partial Judge Header

11626.h

Tags




Discuss