mirror of
https://github.com/theoludwig/programming-challenges.git
synced 2024-10-29 22:17:23 +01:00
feat(challenges): add single-number
This commit is contained in:
parent
2386ea012d
commit
c49f8e1c61
@ -43,13 +43,13 @@ The characters that are not in the intervals `[a-z]` or `[A-Z]` will be shown as
|
|||||||
|
|
||||||
### Constraints
|
### Constraints
|
||||||
|
|
||||||
- 0 < W < 30
|
- $$0 < W < 30$$
|
||||||
- 0 < H < 30
|
- $$0 < H < 30$$
|
||||||
- 0 < N < 200
|
- $$0 < N < 200$$
|
||||||
|
|
||||||
## Source
|
## Source
|
||||||
|
|
||||||
- [CodinGame](https://www.codingame.com/training/easy/ascii-art)
|
[CodinGame](https://www.codingame.com/training/easy/ascii-art)
|
||||||
|
|
||||||
## Examples
|
## Examples
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@ Create a function that will return the sentence after shifting the alphabet.
|
|||||||
|
|
||||||
## Source
|
## Source
|
||||||
|
|
||||||
- [Wikipedia - Caesar cipher](https://en.wikipedia.org/wiki/Caesar_cipher)
|
[Wikipedia - Caesar cipher](https://en.wikipedia.org/wiki/Caesar_cipher)
|
||||||
|
|
||||||
## Examples
|
## Examples
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@ available ingredients.
|
|||||||
|
|
||||||
## Source
|
## Source
|
||||||
|
|
||||||
- [SWERC 2020–2021 - Problem E: Cake](https://swerc.eu/2020/problems/)
|
[SWERC 2020–2021 - Problem E: Cake](https://swerc.eu/2020/problems/)
|
||||||
|
|
||||||
## Examples
|
## Examples
|
||||||
|
|
||||||
|
@ -48,11 +48,11 @@ The name of the defibrillator located the closest to the user’s position.
|
|||||||
|
|
||||||
### Constraints
|
### Constraints
|
||||||
|
|
||||||
- 0 < `N` < 10 000
|
- $$0 < N < 10 000$$
|
||||||
|
|
||||||
## Source
|
## Source
|
||||||
|
|
||||||
- [CodinGame](https://www.codingame.com/training/easy/defibrillators)
|
[CodinGame](https://www.codingame.com/training/easy/defibrillators)
|
||||||
|
|
||||||
## Examples
|
## Examples
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ The order of the generated permutations is important, see the example below.
|
|||||||
|
|
||||||
## Source
|
## 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
|
## Examples
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ Write a program that prints the next term of the **look-and-say sequence**.
|
|||||||
|
|
||||||
## Source
|
## 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
|
## Examples
|
||||||
|
|
||||||
|
@ -24,15 +24,15 @@ You are given a list of `n` array definitions and your job is to figure out what
|
|||||||
|
|
||||||
### Constraints
|
### Constraints
|
||||||
|
|
||||||
- 1 <= `n` <= 100
|
- $$1 <= n <= 100$$
|
||||||
- Array names consist only of uppercase letters A to Z
|
- Array names consist only of uppercase letters A to Z.
|
||||||
- Array lengths are between 1 and 100 (no empty arrays)
|
- Array lengths are between 1 and 100 (no empty arrays).
|
||||||
- Indexing operations have at most 50 levels of nesting
|
- Indexing operations have at most 50 levels of nesting.
|
||||||
- Indices are always within bounds in the test cases
|
- Indices are always within bounds in the test cases.
|
||||||
|
|
||||||
## Source
|
## Source
|
||||||
|
|
||||||
- [CodinGame](https://www.codingame.com/ide/puzzle/offset-arrays)
|
[CodinGame](https://www.codingame.com/ide/puzzle/offset-arrays)
|
||||||
|
|
||||||
## Examples
|
## Examples
|
||||||
|
|
||||||
|
@ -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 **prefix** of the first, `false` otherwise
|
||||||
- **Line 1:** `true` if the second word is a **suffix** 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 - Prefix](https://en.wikipedia.org/wiki/Prefix)
|
||||||
- [Wikipedia - Suffix](https://en.wikipedia.org/wiki/Suffix)
|
- [Wikipedia - Suffix](https://en.wikipedia.org/wiki/Suffix)
|
||||||
|
@ -20,7 +20,7 @@ All the numbers are integers; you don't need to worry about floating point numbe
|
|||||||
|
|
||||||
## Source
|
## Source
|
||||||
|
|
||||||
- [Reverse polish notation - Codewars](https://www.codewars.com/kata/52f78966747862fc9a0009ae)
|
[Reverse polish notation - Codewars](https://www.codewars.com/kata/52f78966747862fc9a0009ae)
|
||||||
|
|
||||||
## Examples
|
## Examples
|
||||||
|
|
||||||
|
@ -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 1:** The string : `arabic to roman` or `roman to arabic` to determine how to convert the number
|
||||||
- **Line 2:** The number to convert
|
- **Line 2:** The number to convert
|
||||||
|
|
||||||
## Source
|
## Sources
|
||||||
|
|
||||||
- [Wikipedia - Roman numerals](https://en.wikipedia.org/wiki/Roman_numerals)
|
- [Wikipedia - Roman numerals](https://en.wikipedia.org/wiki/Roman_numerals)
|
||||||
- [Wikipedia - Arabic numerals](https://en.wikipedia.org/wiki/Arabic_numerals)
|
- [Wikipedia - Arabic numerals](https://en.wikipedia.org/wiki/Arabic_numerals)
|
||||||
|
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
|
@ -20,7 +20,7 @@ Write a function that takes a list of integers and sort them in ascending order.
|
|||||||
|
|
||||||
## Source
|
## Source
|
||||||
|
|
||||||
- [Wikipedia - Sorting algorithm](https://en.wikipedia.org/wiki/Sorting_algorithm)
|
[Wikipedia - Sorting algorithm](https://en.wikipedia.org/wiki/Sorting_algorithm)
|
||||||
|
|
||||||
## Examples
|
## Examples
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ The empty cells are represented by 0.
|
|||||||
|
|
||||||
## Source
|
## Source
|
||||||
|
|
||||||
- [Wikipedia - Sudoku](https://en.wikipedia.org/wiki/Sudoku)
|
[Wikipedia - Sudoku](https://en.wikipedia.org/wiki/Sudoku)
|
||||||
|
|
||||||
## Examples
|
## Examples
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user