" You are given an array of length n containing numbers from 1 to n.
" One number is present twice in the array and one is missing.
" You have to find these two numbers.
Say, if n=7, then the array of numbers should have been something like [3,6,2,5,1,4,7].
Here all the numbers from 1 to 7 are appearing.
But, we are given an array [3,6,2,5,1,2,7]. In this array, the element '2' repeats itself and is present in the place of element '4'. So, we are supposed to print both the missing as well as the repeating number.
Reader, we can't use the XOR directly on the input array because it requires duplicacy. If we use XOR on [3,6,2,5,1,2,7], the duplicate 2's will cancel each other and we will be left with 3^6^5^1^7 which solves no purpose.