20. Single number
In xs, every value appears exactly twice except one, which appears once. Write singleNumber xs, the value that appears once.
Examples
- Input
singleNumber [2, 2, 1]Output1 - Input
singleNumber [4, 1, 2, 1, 2]Output4
Submitting also runs 5 hidden tests.
Constraints
- The list always has exactly one value that appears once.
- Try to use constant extra memory.
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