...

/

Solution: Find All Duplicates in an Array

Solution: Find All Duplicates in an Array

Let’s solve the Find All Duplicates in an Array problem using the Cyclic Sort pattern.

Statement

Given an integer array, nums, of length nn, where all the integers of nums are in the range [1,n][1, n] and each integer appears once or twice, return an array of all the integers that appear twice.

Note: Write an algorithm that runs in O(n) ...