Repeat and Missing Number in Array

Medium

You are given a list nums of size n. Each number in nums lies from 1 to n.
Each integer appears exactly once, except x which appears twice, and y which doesn't appear at all.

Find x and y. Return them as an array [x, y].

Example
nums: [3, 2, 1, 2]
Answer: [2, 4]

Testing

Input Format

The first line contains an integer ‘T’ denoting the number of test cases.

For each test case, the input has two lines:

  • The first line has a positive integer ‘n’.
  • The second line has n space-separated integers denoting the list nums.

Output Format

For each test case, the output has one line containing two space-separated integers x and y.

Sample Input

2
4
3 2 1 2
5
5 3 2 4 3

Expected Output

2 4
3 1

Constraints

1 <= T <= 100
1 <= n <= 1000

Companies
Editorial Link: Editorial