CJCoding With Joseph
15free / daySign inCreate account

Find The Missing Number

Write missing_number(values: list[int]) -> int: the list holds every whole number from 1 to n exactly once except one, in any order, where n is one more than the length of the list. Put the values into a set called present, loop over range(1, n + 1) and return the first number that is not in the set; return -1 after the loop if nothing is missing. Do NOT write a main block or any top-level test code; the tests construct the calls. Input: one line of space-separated integers; the tests print the number your function returns.

Expected Output:

2

= newline. The output ends with a newline — print one after the last line.

Hints3 available
Topics:
Data Structures & Algorithms
📥 Auto-Input:
3 1 4 5\n
This input is automatically fed to your program's stdin
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Ctrl+Space to expand shortcuts (pr, inp, def)

Your Output

Run your code to see the output here...

Test Cases

Run your code to see test case results.