Easy Solution C++|| for loop


#1
string Solution::countAndSay(int n) {
     string s="1";
        n--;
        while(n--)
        {
            string k="";
          for(int i=0;i<s.length();)
          {
              int c=1;
              
              for(int j=i+1;j<s.length();j++)
              {
                  if(s[i]==s[j])c++;
                  else break;
              }
              k+=to_string(c)+s[i];
              i=i+c;
   
          }
            s=k;  
           }
        return s;
}