标签:-- string pre leetcode code == ret ++ cpp
class Solution {
public:
string countAndSay(int n) {
string str,ans;
str="1";
if(n--==1) return str;
while(n--){
ans.clear();
int left=0,right=0;
while(right<str.size()){
if(str[right]==str[left]) right++;
else{
ans+=(right-left+‘0‘);
ans+=str[left];
left=right;
right++;
}
}
ans+=(right-left+‘0‘);
ans+=str[left];
str=ans;
}
return ans;
}
};
标签:-- string pre leetcode code == ret ++ cpp
原文地址:https://www.cnblogs.com/lettleshel/p/9017257.html