038.Count and Say Posted on 2017-09-13 | In LeetCode Solution 1: acceptedThis is a hard one. 1234567891011121314151617181920212223242526public class Solution { public String countAndSay(int n) { StringBuilder curr=new StringBuilder("1"); StringBuilder prev; int count; char say; for (int i=1;i<n;i++){ prev=curr; curr=new StringBuilder(); count=1; say=prev.charAt(0); for (int j=1,len=prev.length();j<len;j++){ if (prev.charAt(j)!=say){ curr.append(count).append(say); count=1; say=prev.charAt(j); } else count++; } curr.append(count).append(say); } return curr.toString(); }}