• Courses
  • Tutorials
  • DSA
  • Data Science
  • Web Tech
August 13, 2024 |7.8K Views

Find duplicates in O(n) time and O(1) extra space

  Share   Like
Description
Discussion

Given an array of n elements that 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.

Example:

Input : n = 7 and array[] = {1, 2, 3, 6, 3, 6, 1}
Output: 1, 3, 6

Explanation: The numbers 1 , 3 and 6 appears more
than once in the array.

Find duplicates in O(n) time and O(1) extra space: https://www.geeksforgeeks.org/find-duplicates-in-on-time-and-constant-extra-space/