Given an integer array, return true if any value appears at least twice. Sorting makes equal values adjacent, so a single linear scan can detect duplicates.
nums = array of integers
true if any duplicate exists
Example 1:
Input:
nums = [1,2,3,1]
Output:
true
Explanation:
1 appears more than once.
Example 2:
Input:
nums = [1,2,3,4]
Output:
false
Explanation:
All values are distinct.