You are given an array of n+2 integer elements. All elements of the array are in range 1 to n. And all elements occur once except two numbers which occur twice. Find the two repeating num
Answers
Answered by
2
Answer:
To the right of 6 there is 1 smaller element (1). To the right of 1 there is 0 smaller element. The trivial solution is pretty obvious. For every number in our nums array, we just iterate through the rest of the array and count all of the numbers that are less than that specific number.
Similar questions