Array Duplicate LeetCode (Find the duplicate number)

Given an array of n elements which contains elements from 0 to n-1, with any of these numbers appearing any number of times. Find these repeating numbers in O(n) and using only constant memory space.

For example, let n be 7 and array be {1, 2, 3, 1, 3, 6, 6}, the answer should be 1, 3 and 6.

This is straightforward problem and is well discussed in LeetCode and its discussion forum A collection of hundreds of interview questions and solutions are available in our blog at Interview Question


Solution

No comments:

Post a Comment