Home
Log in
DescriptionSubmissionsSolution
DescriptionSubmissionsSolution
Loading...

Log in to run or submit

nums =

Codey

Practise coding problems, test your solutions and track your progress.

Explore

  • Problems
  • About
  • Contact

Legal

  • Privacy Policy
  • Terms of Use

© 2026 Codey. Personal learning project.

Solution
Updated: 2026-02-23

Idea

Use a hash set to track numbers seen so far.

Approach

Iterate through the array. If the current number is already in the set, a duplicate exists. Otherwise add it to the set.

Why it works

A set provides O(1) average membership checks, so the first repeated value is detected immediately.

Code
Loading...
Complexity
Time: O(n)
Space: O(n)
Solution
Updated: 2026-02-23

Idea

Use a hash set to track numbers seen so far.

Approach

Iterate through the array. If the current number is already in the set, a duplicate exists. Otherwise add it to the set.

Why it works

A set provides O(1) average membership checks, so the first repeated value is detected immediately.

Code
Loading...
Complexity
Time: O(n)
Space: O(n)