CodeCollection2018
8/11/2019 - 3:07 AM

count and say

1,11,21,1211,111221,312211,13112221,1113213211.。。。。

public String nthSeq(int n){
    String temp ="1";
    if(n==1) return temp;
    int num = n;
    while(num--!=0){
        StringBuilder r = new StringBuilder();
        for(int i =0; i < temp.length();){
            char cur = temp.charAt(i);
            int num_cur = 0;
            while(i < temp.length() && temp.charAt(i)==cur){
                num_cur++;
            }
            i += num_cur;
            r.append(String.valueOf(num_cur)+cur);
        }
        temp  = r.toString();
    }
    return temp;
}