diff --git a/cpp/_3223.cpp b/cpp/_3223.cpp new file mode 100644 index 0000000000..c79a5cd8b4 --- /dev/null +++ b/cpp/_3223.cpp @@ -0,0 +1,17 @@ +class Solution { +public: + int minimumLength(string s) { + vector freq(26, 0); + for(char c : s) { + freq[c - 'a']++; + } + int del = 0; + for(int i = 0; i < 26; i++) { + while(freq[i] >= 3) { + freq[i] -= 2; + del += 2; + } + } + return s.length() - del; + } +};