52. Missing number
xs contains every number from 0 to n exactly once, except one, where n is the length of xs. Write missingNumber xs, the number that is missing.
The tests include long lists, so aim for one pass over the list.
Examples
- Input
missingNumber [3, 0, 1]Output2 - Input
missingNumber [0, 1]Output2 - Input
missingNumber [9, 6, 4, 2, 3, 5, 7, 0, 1]Output8
Submitting also runs 6 hidden tests.
Loading editor…
Type
\to in the editor, or click:Run checks your code against the examples and your custom inputs and records nothing. Submit also runs the hidden tests, confirms the axioms your proof uses and records the result. Each uses one compiler check.
ReadyLn 1, Col 1Lean 4
Draft saved in this browser