Arrays · Python
First Duplicate
Problem
Return the first duplicate value encountered from left to right, or -1 if none exists.
Example input
nums = [2, 1, 3, 5, 3, 2]
Example output
3
Constraints
1 <= len(nums) <= 100,000
Python workspace
Execution uses a timed child process in a temporary directory. It is development-only isolation, not a production sandbox.