mirror of
https://github.com/theoludwig/programming-challenges.git
synced 2024-12-08 00:45:29 +01:00
feat(challenge): first non-repeating character
This commit is contained in:
parent
954cd934b7
commit
721396e429
19
challenges/first-non-repeating-character/README.md
Normal file
19
challenges/first-non-repeating-character/README.md
Normal file
@ -0,0 +1,19 @@
|
||||
# first-non-repeating-character
|
||||
|
||||
Created by [@Divlo](https://github.com/Divlo) on 15 November 2020.
|
||||
|
||||
## Instructions :
|
||||
|
||||
Write a function that takes a string input, and returns the first character that is not repeated anywhere in the string.
|
||||
|
||||
For example, if given the input `'stress'`, the function should return `'t'`, since the letter _t_ only occurs once in the string, and occurs first in the string.
|
||||
|
||||
If a string contains all repeating characters, it should return an empty string (`""`).
|
||||
|
||||
## Source :
|
||||
|
||||
[First non-repeating character - Codewars](https://www.codewars.com/kata/52bc74d4ac05d0945d00054e/)
|
||||
|
||||
## Examples :
|
||||
|
||||
See the `input-output.json` file for examples of input/output.
|
34
challenges/first-non-repeating-character/input-output.json
Normal file
34
challenges/first-non-repeating-character/input-output.json
Normal file
@ -0,0 +1,34 @@
|
||||
[
|
||||
{
|
||||
"input": ["a"],
|
||||
"output": "a"
|
||||
},
|
||||
{
|
||||
"input": ["stress"],
|
||||
"output": "t"
|
||||
},
|
||||
{
|
||||
"input": ["moonmen"],
|
||||
"output": "e"
|
||||
},
|
||||
{
|
||||
"input": [""],
|
||||
"output": ""
|
||||
},
|
||||
{
|
||||
"input": ["abba"],
|
||||
"output": ""
|
||||
},
|
||||
{
|
||||
"input": ["aa"],
|
||||
"output": ""
|
||||
},
|
||||
{
|
||||
"input": ["~><#~><"],
|
||||
"output": "#"
|
||||
},
|
||||
{
|
||||
"input": ["hello world, eh?"],
|
||||
"output": "w"
|
||||
}
|
||||
]
|
Loading…
Reference in New Issue
Block a user