Given an array integer which comprises of numbers 1 to 100, with one duplicate number. How will you find the duplicate number in array?
As we know sum of n natural numbers =
Hence first calculate the sum of given numbers and then subtract the sum of n natural numbers from it. You will get the dulicate number in an array.