Surface the Repeat Offenders
Advanced SolvedA fraud check flags values that appear more than once in a transaction stream. Report each repeated value a single time, in the order it first becomes a repeat.
Implement `solve(List<Integer> nums)` to return the values that appear more than once, each listed once, in the order each first becomes a duplicate.
Examples
Input
[4, 3, 2, 7, 3, 2, 2]Output
[3, 2]Input
[1, 1, 1]Output
[1]Hints
- Track seen and already-added values in two Sets while scanning.
Tests
Your code runs in a secure sandbox against multiple hidden test cases. The problem is solved only when every test passes. Each run is isolated and any data changes are rolled back automatically.