class Solution { public: int compress(vector& chars) { int count = 0; vector compressed = {}; char temp = chars.at(0); for (int i = 0; i < chars.size(); i++) { char current = chars.at(i); if (temp == current) // If temp and current == same then increase count { count++; } else { compressed.push_back(temp); if (1 < count) { string s = to_string(count); for (char c : s) { compressed.push_back(c); } } temp = current; count = 1; } } compressed.push_back(temp); if (1 < count) { string s = to_string(count); for (char c : s) { compressed.push_back(c); } } chars = compressed; return (compressed.size()); // Get the size of the letters found + the amount found and return it } };