Find the repeating and the missing

1

4 votes
Easy
Problem

Given an unsorted array of size n. Array elements are in range from 1 to n. One number from set {1, 2, …n} is missing and one number occurs twice in array. Find these two numbers.

Sample Input
3 1 3
Sample Output
2 3
Time Limit: 5
Memory Limit: 256
Source Limit:
Explanation

arr[] = {3, 1, 3} Output: 2, 3 // 2 is missing and 3 occurs twice

Editor Image

?