Skip to content

Commit 27b7578

Browse files
authored
Create 3541. Find Most Frequent Vowel and Consonant (#884)
2 parents 3b17c80 + 28ddc54 commit 27b7578

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
class Solution {
2+
public:
3+
int maxFreqSum(string s) {
4+
int n = s.size();
5+
int hash[26] = {0};
6+
for(int i =0;i<n;i++){
7+
hash[s[i]-'a']++;
8+
}
9+
int vmax=0,cmax=0;
10+
for(int i =0;i<26;i++){
11+
if(i == 0 || i == 4 || i == 8 || i == 14 || i == 20){
12+
vmax = max(vmax,hash[i]);
13+
}else{
14+
cmax = max(cmax,hash[i]);
15+
}
16+
}
17+
return vmax + cmax;
18+
}
19+
};

0 commit comments

Comments
 (0)