Duplicate sample IDs: right answer, too slow
Target time: 15 minutes.
Ticket
Both functions give the right answers, and the correctness tests pass. But on a real day's intake (around 200,000 IDs) the nightly check takes hours. The speed tests time each function on an input, then on one 8 times bigger. Linear code gets about 8 times slower. These get about 64 times slower.
Make both functions O(n) without changing what they return.
Before you change anything
Say out loud what the current complexity is and why. Point at the exact line that makes it slow. In an interview that sentence is worth as much as the fix.
Files
sample_ids.pytest_sample_ids.py(the tests are correct; don't change them)