An upload queue gives each of n uploads an id from 1 to n. A retry bug made some ids appear twice (none appear more than twice). The ids are in ids.
Write duplicateIds(ids) that returns every id that appears twice, in increasing order. Use O(1) extra memory besides the answer.
Input: ids = [5,3,1,5,3,2] Output: [3,5]
3 and 5 each appear twice.
Input: ids = [1,2,3] Output: []
No id repeats.
1 <= ids.length <= 10^51 <= ids[i] <= ids.lengthRun tries your code on the examples. Submit runs every test, including hidden edge cases, and solves the problem when they all pass.
Ctrl + Enter runs, Ctrl + Shift + Enter submits (⌘ on a Mac).
I'm here to help with #73 Duplicate Upload IDs. I give hints, never the solution, so you get to solve it yourself. Ask for a hint, select code to ask about it, or press Ask Tuto why on a failing test.
Your first 3 answers need no account. for free to keep asking.