Find All Duplicates in an Array
Medium · Hashing · about 15 minutes
Asked at Google, Amazon, Microsoft, ByteDance, Bloomberg.
In an integer array nums of length n, every value is in 1..n and appears once or twice. Return every value that appears twice, in any order, using O(n) time and only constant extra space.