题目
class Solution {public String countAndSay(int n) {String ret = "1";for(int i=1;i<n;i++)//解释n-1次ret{StringBuffer tmp = new StringBuffer();int len = ret.length();for(int left = 0,right = 0;right<len;){//双指针while(right < len && ret.charAt(left) == ret.charAt(right))right++;tmp.append(Integer.toString(right - left));//个数tmp.append(ret.charAt(left));//字符left = right;}ret = tmp.toString();}return ret;}
}