HHP Inc·DSASDE-1Online Assessment
K-th Duplicate Element in an Array
Problem
Find the k-th element that appears more than once, in order of first reaching a duplicate.
Example
[1,2,1,3,2,1], k=2 -> 2
Constraints
- 1 ≤ n ≤ 10^5
Approach
Hash map of counts while scanning; emit on the k-th element crossing count 2. Reported HP question.
added 6 days ago