public class Solution {
/**
* @param n the nth
* @return the nth sequence
*/
public String countAndSay(int n) {
// Write your code here
if(n==0){
return "1";
}
String []result=new String[n];
result[0]="1";
for(int i=1;i<n;i++){
String str=result[i-1];
String temp="";
int count=1;
for(int j=1;j<str.length();j++){
if(str.charAt(j-1)==str.charAt(j)){
count++;
}else{
temp+=count+""+str.charAt(j-1);
count=1;
}
}
temp+=count+""+str.charAt(str.length()-1);
result[i]=temp;
}
return result[n-1];
}
}