1
1
mirror of https://github.com/theoludwig/programming-challenges.git synced 2024-12-08 00:45:29 +01:00

feat(challenges): add single-number

This commit is contained in:
Théo LUDWIG 2023-08-21 23:11:08 +02:00
parent 2386ea012d
commit c49f8e1c61
Signed by: theoludwig
GPG Key ID: ADFE5A563D718F3B
20 changed files with 74 additions and 21 deletions

View File

@ -43,13 +43,13 @@ The characters that are not in the intervals `[a-z]` or `[A-Z]` will be shown as
### Constraints
- 0 < W < 30
- 0 < H < 30
- 0 < N < 200
- $$0 < W < 30$$
- $$0 < H < 30$$
- $$0 < N < 200$$
## Source
- [CodinGame](https://www.codingame.com/training/easy/ascii-art)
[CodinGame](https://www.codingame.com/training/easy/ascii-art)
## Examples

View File

@ -27,7 +27,7 @@ Create a function that will return the sentence after shifting the alphabet.
## Source
- [Wikipedia - Caesar cipher](https://en.wikipedia.org/wiki/Caesar_cipher)
[Wikipedia - Caesar cipher](https://en.wikipedia.org/wiki/Caesar_cipher)
## Examples

View File

@ -32,7 +32,7 @@ available ingredients.
## Source
- [SWERC 20202021 - Problem E: Cake](https://swerc.eu/2020/problems/)
[SWERC 20202021 - Problem E: Cake](https://swerc.eu/2020/problems/)
## Examples

View File

@ -48,11 +48,11 @@ The name of the defibrillator located the closest to the users position.
### Constraints
- 0 < `N` < 10 000
- $$0 < N < 10 000$$
## Source
- [CodinGame](https://www.codingame.com/training/easy/defibrillators)
[CodinGame](https://www.codingame.com/training/easy/defibrillators)
## Examples

View File

@ -10,7 +10,7 @@ The order of the generated permutations is important, see the example below.
## Source
- [Heap's Algorithm - Wikipedia](https://en.wikipedia.org/wiki/Heap%27s_algorithm)
[Heap's Algorithm - Wikipedia](https://en.wikipedia.org/wiki/Heap%27s_algorithm)
## Examples

View File

@ -20,7 +20,7 @@ Write a program that prints the next term of the **look-and-say sequence**.
## Source
- [Look-and-say sequence - Wikipedia](https://en.wikipedia.org/wiki/Look-and-say_sequence)
[Look-and-say sequence - Wikipedia](https://en.wikipedia.org/wiki/Look-and-say_sequence)
## Examples

View File

@ -24,15 +24,15 @@ You are given a list of `n` array definitions and your job is to figure out what
### Constraints
- 1 <= `n` <= 100
- Array names consist only of uppercase letters A to Z
- Array lengths are between 1 and 100 (no empty arrays)
- Indexing operations have at most 50 levels of nesting
- Indices are always within bounds in the test cases
- $$1 <= n <= 100$$
- Array names consist only of uppercase letters A to Z.
- Array lengths are between 1 and 100 (no empty arrays).
- Indexing operations have at most 50 levels of nesting.
- Indices are always within bounds in the test cases.
## Source
- [CodinGame](https://www.codingame.com/ide/puzzle/offset-arrays)
[CodinGame](https://www.codingame.com/ide/puzzle/offset-arrays)
## Examples

View File

@ -20,7 +20,7 @@ Write a programs that takes 2 strings ("words") and prints if one is a prefix/su
- **Line 1:** `true` if the second word is a **prefix** of the first, `false` otherwise
- **Line 1:** `true` if the second word is a **suffix** of the first, `false` otherwise
## Source
## Sources
- [Wikipedia - Prefix](https://en.wikipedia.org/wiki/Prefix)
- [Wikipedia - Suffix](https://en.wikipedia.org/wiki/Suffix)

View File

@ -20,7 +20,7 @@ All the numbers are integers; you don't need to worry about floating point numbe
## Source
- [Reverse polish notation - Codewars](https://www.codewars.com/kata/52f78966747862fc9a0009ae)
[Reverse polish notation - Codewars](https://www.codewars.com/kata/52f78966747862fc9a0009ae)
## Examples

View File

@ -35,7 +35,7 @@ Here are the rules for building a Roman numeral:
- **Line 1:** The string : `arabic to roman` or `roman to arabic` to determine how to convert the number
- **Line 2:** The number to convert
## Source
## Sources
- [Wikipedia - Roman numerals](https://en.wikipedia.org/wiki/Roman_numerals)
- [Wikipedia - Arabic numerals](https://en.wikipedia.org/wiki/Arabic_numerals)

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

View File

@ -20,7 +20,7 @@ Write a function that takes a list of integers and sort them in ascending order.
## Source
- [Wikipedia - Sorting algorithm](https://en.wikipedia.org/wiki/Sorting_algorithm)
[Wikipedia - Sorting algorithm](https://en.wikipedia.org/wiki/Sorting_algorithm)
## Examples

View File

@ -20,7 +20,7 @@ The empty cells are represented by 0.
## Source
- [Wikipedia - Sudoku](https://en.wikipedia.org/wiki/Sudoku)
[Wikipedia - Sudoku](https://en.wikipedia.org/wiki/Sudoku)
## Examples