Find All Duplicates in an Array

Given an integer array nums of length n, where 1 <= nums[i] <= n and each integer appears either once or twice, return every integer that appears exactly twice.

Requirements:

  • O(n) time;
  • ...

Example

Unlock to view complete problem details

and practice with sample input/output

Was this article helpful?

View Test Cases & Run Code requires membership

Standard Input
Execution Result: