A paginated API should have returned pages 1 to n, where n is the number of responses received. Some pages came back twice, so others never arrived. The page numbers received are in pages.
Write missingPages(pages) that returns every number from 1 to n that is not in pages, in increasing order. Use O(1) extra memory besides the answer.
Input: pages = [3,5,2,3,1,5] Output: [4,6]
3 and 5 came twice, so pages 4 and 6 never arrived.
Input: pages = [1,2,3] Output: []
Every page arrived.
1 <= pages.length <= 10^51 <= pages[i] <= pages.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 #71 Missing Page Numbers. 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.