水题
class Solution {
public String next(String num) {
String ans = "";
int i = 0;
while (i < num.length()) {
char ch = num.charAt(i);
int cnt = 0;
while (i < num.length() && ch == num.charAt(i)) {
i++;
cnt++;
}
ans += cnt;
ans += ch;
}
return ans;
}
public String countAndSay(int n) {
String num = "1";
while (--n > 0) {
num = next(num);
}
return num;
}
}