-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSimplestringcharacters.cpp
More file actions
61 lines (54 loc) · 1.32 KB
/
Simplestringcharacters.cpp
File metadata and controls
61 lines (54 loc) · 1.32 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
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include <string>
#include <iostream>
using namespace std;
vector<int> solve(string s)
{
vector<int>result;
int uppercasee = 0;
int lowercase = 0;
int numbers = 0;
int spacial = 0;
for (int i = 0; i < s.size(); i++)
{
if (s[i] >= '0' && s[i] <= '9')
{
numbers++;
}
else if (s[i] >= 'a' && s[i] <= 'z')
{
lowercase++;
}
else if (s[i] >= 'A' && s[i] <= 'Z')
{
uppercasee++;
}
else
{
spacial++;
}
}
result.push_back(uppercasee);
result.push_back(lowercase);
result.push_back(numbers);
result.push_back(spacial);
return result;
}
int main() {
vector<int>ss = solve("RYT'>s&gO-.CM9AKeH?,5317tWGpS<*x2ukXZD");
for (int i = 0; i < ss.size(); i++)
{
cout << ss[i];
}
return 0;
}
/*Description:
In this Kata, you will be given a string and your task will be to return a list of ints detailing the count of uppercase letters, lowercase, numbers and special characters, as follows.
Solve("*'&ABCDabcde12345") = [4,5,5,3].
--the order is: uppercase letters, lowercase, numbers and special characters.
More examples in the test cases.
Good luck!
Fundamentals*/