Cpp c++ solution


#1

string Solution::countAndSay(int A) {
if(A==0){
return “”;
}
if(A==1){
return “1”;
}
string s=“1”;
int j=1;
while(j<A){
int c=1;
string s1="";
for (int i=0; i<s.size()-1; i++){
if(s[i]==s[i+1]){
c++;
}
else{
s1+=to_string©+s[i];
c=1;
}
}
s1+=to_string©+s[s.size()-1];
s=s1;
j++;
}
return s;
}