Loading...
Loading...
Loading...
Invoices are numbered 1 to n. One number is missing from the list you receive, which holds the other n - 1 numbers in any order. Print the missing number.
Example
Input
5 2 5 1 4
Output
3
Try the problem first. Open one hint at a time.
Checking i in numbers for each i from 1 to n scans the list each time: O(n²).
The sum of 1..n is n * (n + 1) // 2. What remains after you subtract the sum of the list?
Write your Python code, run it on the examples and submit it to hidden tests.
Solve in the editor