public class Solution {
//dfs 算法还待写吧 http://www.cnblogs.com/huntfor/p/3849547.html
public String countAndSay(int n) {
if(n<=0) return null;
String s = "1";
int cnt =1;
for(int i=0; i<n-1 ; i++){
StringBuilder t = new StringBuilder();
for(int j=0; j< s.length(); j++){
if(j<s.length()-1 && s.charAt(j)==s.charAt(j+1)){
cnt++;
}else{
t.append(cnt+""+s.charAt(j));
cnt=1;
}
}
s = t.toString();
}
return s;
}
}
难点在于不知道题目是什么意思,实际就是写然后读,然后按照读出的数组再写
ref: http://www.cnblogs.com/huntfor/p/3849547.html
dfs算法没搞