-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFindthemissingletter.cpp
More file actions
52 lines (45 loc) · 1.3 KB
/
Findthemissingletter.cpp
File metadata and controls
52 lines (45 loc) · 1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#include<iostream>
#include <string>
#include<vector>
using namespace std;
char findMissingLetter(const vector<char>& chars)
{
char result;
for (int i = 0; i < chars.size() - 1; i++)
{
if (chars[i] != chars[i + 1] - 1)
{
result = chars[i + 1] - 1;
}
}
return result;
}
int main()
{
cout << findMissingLetter({ 'O', 'Q', 'R', 'S' });
return 0;
}
/*Description:
Find the missing letter
Write a method that takes an array of consecutive (increasing) letters as input and that returns the missing letter in the array.
You will always get an valid array. And it will be always exactly one letter be missing.
The length of the array will always be at least 2.
The array will always contain letters in only one case.
Example:
['a','b','c','d','f'] -> 'e'
['O','Q','R','S'] -> 'P'
(Use the English alphabet with 26 letters!)
Have fun coding it and please don't forget to vote and rank this kata! :-)
I have also created other katas. Take a look if you enjoyed this kata!
Mathematics
Algorithms*/
// /> フ
// | n n 彡
// /`ミ_xノ
// / |
// / ヽ ノ
// │ | | |
// / ̄| | | |
// | ( ̄ヽ__ヽ_)__)
// \二つ
// ITS CAT FOR YOU