Algorithm · Microsoft · Easy
Given an array values of signed 32‑bit integers, scan the array from left to right and return the first value that appears for the second time. In other words, return the element whose second occurrence comes earliest in the scan order. If every element is unique, return ‑1. Because ‑1 is a valid array element, the function may return ‑1 both when a duplicate has the value ‑1 and when no duplicate exists — this is an intentional ambiguity; do not attempt to resolve it inside…
Checking your access…