The Super Simplest Solution ever using Recursion


#1

string Solution::countAndSay(int A) {
if(A==1){
return “1”;
}

string a =countAndSay(A-1);
int count=0;
string ans="";
for(int i=0;i<a.size();i++){
    count++;
    if(a[i]!=a[i+1]){
        ans+=to_string(count)+a[i];
        count=0;
    }
}
return ans;

}