You are given an array of integers `elements` containing at least one duplicate. Find the index of the first occurrence of a duplicate element in the array.
Explanation: the first occurrence of duplicate 3 is at index 3
Explanation: the first occurrence of duplicate 5 is at index 1
Explanation: the first occurrence of duplicate 1 is at index 0
Analyze constraints and compute optimal solutions step-by-step.
No dry run loaded.
🚀 Practice this problem
Run code, get AI hints & track streak