#K47467. Find the Missing and Repeated Number
Find the Missing and Repeated Number
Find the Missing and Repeated Number
You are given an array of n integers which is supposed to contain all the numbers from 1 to n. However, one number is missing and one number occurs twice. Your task is to find the repeated number and the missing number.
Example:
Input: 5 4 3 6 2 2 Output: 2 5
In the sample, the array length n is 5. Although the numbers should be from 1 to 5, one of the numbers appears twice and another is missing. Here, 2 appears twice and 5 is missing.
Note: The input is read from standard input (stdin) and the result should be printed to standard output (stdout).
inputFormat
The first line contains a single integer n — the number of elements in the array. The second line contains n space-separated integers representing the array. It is guaranteed that exactly one number is repeated and exactly one number is missing from the range [1, n].
outputFormat
Output two integers separated by a space: the repeated number first, followed by the missing number.
## sample5
4 3 6 2 2
2 5