LeetCode38-countAndSay
递归:
if( n == 1) return "1"; String s = countAndSay(n-1); char[] c = s.toCharArray(); int count = 1; String res = ""; for(int i = 0; i < c.length-1; i++){ if(c[i] == c[i+1]){ count++; } else{ res = res + count + c[i]; count = 1; } } return res+count+c[c.length-1];
浙公网安备 33010602011771号