A raffle printed tickets numbered 0 to n, one of each, and sold all but one. The n sold ticket numbers are in tickets, in any order.
Write missingTicket(tickets) that returns the unsold ticket number. Try to solve it in O(n) time with O(1) extra memory.
Input: tickets = [4,2,0,1] Output: 3
Tickets go from 0 to 4, and 3 is not in the list.
Input: tickets = [0] Output: 1
Tickets 0 and 1 were printed, and only 0 was sold.
1 <= tickets.length <= 5 * 10^50 to tickets.length.Run tries your code on the examples. Submit runs every test, including hidden edge cases and big inputs that check your code is fast enough, and solves the problem when they all pass.
Ctrl + Enter runs, Ctrl + Shift + Enter submits (⌘ on a Mac).
I'm here to help with #70 Find the Missing Ticket. 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.