Given an array of integers, return the first element that appears more than once as you scan from left to right.
If no element recurs, return -1.
Important: "First recurring" means the first element where you encounter a duplicate as you read left to right, not the element with the smallest index in the original array.
nums = [2, 5, 1, 2, 3, 5]2nums = [1, 2, 3, 4, 5]-1nums = [3, 1, 3, 1]30 <= nums.length <= 10^4-10^5 <= nums[i] <= 10^5Run your code to see results
Use Cmd+Enter to run