1
1
mirror of https://github.com/theoludwig/programming-challenges.git synced 2025-05-18 12:02:53 +02:00

feat(challenges): add single-number

This commit is contained in:
2023-08-21 23:11:08 +02:00
parent 2386ea012d
commit c49f8e1c61
20 changed files with 74 additions and 21 deletions

View File

@@ -0,0 +1,41 @@
# single-number
Created by [@theoludwig](https://github.com/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](https://leetcode.com/problems/single-number/)
## Examples
See the `test` folder for examples of input/output.
### Example 1
#### Input
```txt
4
1
2
1
2
```
#### Output
```txt
4
```

View File

@@ -0,0 +1,5 @@
4
1
2
1
2

View File

@@ -0,0 +1 @@
4

View File

@@ -0,0 +1,3 @@
2
2
1

View File

@@ -0,0 +1 @@
1

View File

@@ -0,0 +1 @@
1

View File

@@ -0,0 +1 @@
1