You get an integer array nums. Return true if some value shows up two or more times in it, and false if every value is different from all the others.
The two 9s are enough. It doesn't matter that they aren't next to each other.
All four values are different.
A single value has nothing to repeat.
Constraints
1 <= nums.length <= 10⁵-10⁹ <= nums[i] <= 10⁹You only need to know whether a value has turned up before. As you walk the array once, keep a record of the values you've already passed.
A repeat is two positions holding the same value. The direct way to find one is to hold up each value against every other value, which is about n² / 2 comparisons: 5 billion when n = 10⁵.
Time O(n)Space O(n)
The full walkthrough and code are part of Premium
true