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:
41
challenges/single-number/README.md
Normal file
41
challenges/single-number/README.md
Normal 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
|
||||
```
|
0
challenges/single-number/solutions/.gitkeep
Normal file
0
challenges/single-number/solutions/.gitkeep
Normal file
5
challenges/single-number/test/1/input.txt
Normal file
5
challenges/single-number/test/1/input.txt
Normal file
@@ -0,0 +1,5 @@
|
||||
4
|
||||
1
|
||||
2
|
||||
1
|
||||
2
|
1
challenges/single-number/test/1/output.txt
Normal file
1
challenges/single-number/test/1/output.txt
Normal file
@@ -0,0 +1 @@
|
||||
4
|
3
challenges/single-number/test/2/input.txt
Normal file
3
challenges/single-number/test/2/input.txt
Normal file
@@ -0,0 +1,3 @@
|
||||
2
|
||||
2
|
||||
1
|
1
challenges/single-number/test/2/output.txt
Normal file
1
challenges/single-number/test/2/output.txt
Normal file
@@ -0,0 +1 @@
|
||||
1
|
1
challenges/single-number/test/3/input.txt
Normal file
1
challenges/single-number/test/3/input.txt
Normal file
@@ -0,0 +1 @@
|
||||
1
|
1
challenges/single-number/test/3/output.txt
Normal file
1
challenges/single-number/test/3/output.txt
Normal file
@@ -0,0 +1 @@
|
||||
1
|
Reference in New Issue
Block a user