Skip to content

Commit d28d3ce

Browse files
authored
Create _3223.cpp
Solution for Leetcode problem 3223. Minimum Length of String After Operations
1 parent e3f477d commit d28d3ce

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

cpp/_3223.cpp

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
class Solution {
2+
public:
3+
int minimumLength(string s) {
4+
vector<int> freq(26, 0);
5+
for(char c : s) {
6+
freq[c - 'a']++;
7+
}
8+
int del = 0;
9+
for(int i = 0; i < 26; i++) {
10+
while(freq[i] >= 3) {
11+
freq[i] -= 2;
12+
del += 2;
13+
}
14+
}
15+
return s.length() - del;
16+
}
17+
};

0 commit comments

Comments
 (0)