First Value Seen Only Once
Return the value of nums that appears exactly once in the whole list and sits at the smallest position among such values.
If every value appears more than once, or nums is empty, return -1. All values are non-negative, so -1 is never a value of the list.
Example 1
nums [4,7,4,9,7]
returns 9
4 and 7 both appear twice; 9 is the first value that appears only once.
Example 2
nums [2,2,3,3]
returns -1
Both values repeat, so there is no answer.
Constraints
0 <= len(nums) <= 1000 <= nums[i] <= 1000
Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.