Description Given an integer array of n elements, and a set of indices that point to elements in this array, and assuming that some elements have been removed from the array, which would result in indices shift. What would be the new indices after elements removal?
Input & Output The input will be a set of lines. Each input line consists of the following:
The number of elements in the initial array N, followed by a TAB, where N can range from 1 to the maximum integer value.
The set of initial indices that range from 0 to N-1 separated by spaces, followed by a TAB
The set of indices to be removed from the array separated by spaces (in the range from 0 to N-1)
The expected output is a set of new indices that correspond to input (2) after the removal of indices in input (3). If an index is not valid any more, use (-1) as the new index.
Example Input
10 1 3 9 0 5
100 10 99 10
50 10 20 30
Output
0 2 7
-1 98
10 20
In the first example, the first two elements were shifted by 1 because of the removal of element at index 0, and the 3rd element was shifted by 2 because of the removal of the elements at indexes 0 and 5. In the second example, element 10 was replaced by -1 because it was removed. In the third example, no elements are affected.