-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStringarrayduplicates.cpp
More file actions
74 lines (64 loc) · 1.5 KB
/
Stringarrayduplicates.cpp
File metadata and controls
74 lines (64 loc) · 1.5 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include <string>
#include <sstream>
#include <climits>
#include<iomanip>
using namespace std;
vector<string> dup(vector<string> arr) {
vector<string>resultsum;
string result;
for (const string& word : arr)
{
result = "";
result += word[0];
for (int j = 1; j < word.size(); j++)
{
if (word[j] != word[j - 1])
{
result += word[j];
}
else
{
continue;
}
}
resultsum.push_back(result);
}
return resultsum;
}
int main()
{
vector<string>casetast1 = { {"ccooddddddewwwaaaaarrrrsssss","piccaninny","hubbubbubboo"} };
vector<string>result = dup(casetast1);
for (int i = 0; i < casetast1.size(); i++)
{
cout << result[i] << " ";
}
return 0;
}
/*Description:
In this Kata, you will be given an array of strings and your task is to remove all consecutive duplicate letters from each string in the array.
For example:
dup(["abracadabra","allottee","assessee"]) = ["abracadabra","alote","asese"].
dup(["kelless","keenness"]) = ["keles","kenes"].
Strings will be lowercase only, no spaces. See test cases for more examples.
Good luck!
If you like this Kata, please try:
Alternate capitalization
Vowel consonant lexicon
Strings
Arrays
Algorithms*/
// /> フ
// | n n 彡
// /`ミ_xノ
// / |
// / ヽ ノ
// │ | | |
// / ̄| | | |
// | ( ̄ヽ__ヽ_)__)
// \二つ
// ITS CAT FOR YOU