leetcodeSolution to some Leetcode problems written in C++ |
git clone git://git.dimitrijedobrota.com/leetcode.git |
Log | Files | Refs | README | LICENSE |
3223.cpp (331B)
0 class Solution { 1 public: 2 int minimumLength(const string &s) const { 3 int count[26] = {0}; 4 int res = 0; 5 6 for (const char c : s) { 7 count[c - 'a']++; 8 } 9 10 for (int i = 0; i < 26; i++) { 11 res += (count[i] - 1) / 2; 12 } 13 14 return size(s) - 2 * res; 15 } 16 };