简单模拟
根据题目描述,简单的模拟一遍即可。
class Solution {
    public String countAndSay(int n) {
        StringBuilder sb = new StringBuilder("1");
        for (int k = 1; k < n; k++) {
            StringBuilder temp = new StringBuilder();
            int i = 0, j = 0;
            while (i < sb.length()) {
                while (j < sb.length()) {
                    if (sb.charAt(i) != sb.charAt(j)) break;
                    j++;
                }
                temp.append(j - i);
                temp.append(sb.charAt(i));
                i = j;
            }
            sb = temp;
        }
        return sb.toString();
    }
}
原文:https://www.cnblogs.com/fromneptune/p/13255071.html