class Solution {
public:
string
count(string str
){
string res
="";
int l
=0,r
=0;
while(l
<str
.size()){
while(str
[r
]==str
[l
])
r
++;
res
+=(r
-l
+'0');
res
+=str
[l
];
l
=r
;
}
return res
;
}
string
countAndSay(int n
) {
if(n
==1) return "1";
return count(countAndSay(n
-1));
}
};
转载请注明原文地址:https://tech.qufami.com/read-22280.html