Problem Statement
Given an integer array nums, return true if any value appears at least twice in the array, and return false if every element is distinct.
Approach
We use a Hash Set to keep track of the elements we have seen so far. As we iterate through the array, we check if the current number is already in the set. If it is, we define it as a duplicate and return true. If we finish the loop without finding duplicates, we return false.
Time & Space Complexity
Time complexity is O(n) because we do a single pass over the array. Set lookups are O(1) on average. Space complexity is O(n) to store the elements in the set.
