First Duplicate from Left to Right

Given an integer array nums, scan it from left to right and return the first value that appears again: the value whose second occurrence has the smallest index. Return -1 if no value repeats. ...

Example

Unlock to view complete problem details

and practice with sample input/output

Was this article helpful?

View Test Cases & Run Code requires membership

Standard Input
Execution Result: