using namespace std;
string runLengthEncoding(string str) {
vector encodedStringChar;
int counter = 1;
for(int i = 1; i<str.size(); i++){
char currentChar = str[i];
char previousChar = str[i - 1];
if(currentChar != previousChar || counter == 9){
encodedStringChar.push_back(to_string(counter)[0]);
encodedStringChar.push_back(previousChar);
counter = 0;
}
counter ++;
}
encodedStringChar.push_back(to_string(counter)[0]);
encodedStringChar.push_back(str[str.size() - 1]);
string encodedString(encodedStringChar.begin(),
encodedStringChar.end());
return encodedString;
}
this is the complete solution why does it get only accepted when keep the [0] after the to_string(count) even though the converted sting only has 1 character