[Solution] Permutation Clear CodeChef Solution
Problem
Alice has an array of length which is initially a permutation. She dislikes numbers which are all of which are distinct. Therefore, she removes all the occurrences of these numbers from . The order of the remaining elements of the does not change.
Can you find out the resulting array ?
Note: A permutation of length is an array where every integer from to occurs exactly once.
Input Format
- The first line contains a single integer — the number of test cases. Then the test cases follow.
- The first line of each test case contains an integer — the size of the array .
- The second line of each test case contains integers denoting the array .
- The third line of each test case contains an integer — the size of the array .
- The fourth line of each test case contains integers denoting the numbers which Alice dislikes.
Output Format
For each test case, output the resulting array after the removal of all occurrences of .
It is guaranteed that there will be at least one element in the resulting array.
Explanation:
Test Case 1: Here and . The resulting array after removing all the numbers which Alice dislikes is .
Note that here is an incorrect answer since the order of elements should be the same as in the original array.
Test Case 2: Here and . The resulting array after removing all the numbers which Alice dislikes is .
Test Case 3: Here and . The resulting array after removing all the numbers which Alice dislikes is .
No comments:
Post a Comment