20. Single number

EasyProgramFree10 points

In xs, every value appears exactly twice except one, which appears once. Write singleNumber xs, the value that appears once.

Examples

  1. InputsingleNumber [2, 2, 1]Output1
  2. InputsingleNumber [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.
Solution.lean
Loading editor…

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