1
1
mirror of https://github.com/theoludwig/programming-challenges.git synced 2024-07-18 02:20:12 +02:00
programming-challenges/challenges/single-number
2023-08-21 23:11:08 +02:00
..
solutions feat(challenges): add single-number 2023-08-21 23:11:08 +02:00
test feat(challenges): add single-number 2023-08-21 23:11:08 +02:00
README.md feat(challenges): add single-number 2023-08-21 23:11:08 +02:00

single-number

Created by @theoludwig on 21 August 2023.

Instructions

Given a non-empty array of integers, every element appears twice except for one. Find that single one.

You must implement a solution with a linear runtime complexity and use only constant extra space.

Constraints

  • 1 <= numbers.length <= 3 * 10^4
  • -3 * 10^4 <= numbers[index] <= 3 * 10^4
  • Each element in the array appears twice except for one element which appears only once.

Source

LeetCode - Single Number

Examples

See the test folder for examples of input/output.

Example 1

Input

4
1
2
1
2

Output

4