Simple Java solution, 111221 => 312211


#1
public class Solution {
    public String countAndSay(int n) {
          
        StringBuilder ans = new StringBuilder("1");
        for(int i = 1; i<n; i++)
            ans = findNext(ans);
            
        return ans.toString();
    }
    
    public StringBuilder findNext(StringBuilder sb){
        StringBuilder result = new StringBuilder();
        int i =0;
        while(i<sb.length()){
            int j = i; 
            int count = 1;
            while(j < sb.length()-1 && sb.charAt(j) == sb.charAt(j+1)){
                count++;
                j++;
            }
            result.append(count+""+sb.charAt(i));
            i = j+1;
        }
        return result;
        
    }
}