Easiest Java Solution .Just implementing the question statement


#1

public class Solution {
public String countAndSay(int A) {
if(A==1) return “1”;
int i=2;
String prev=“1”;
while(i<=A){
int count=1;
String s="";
for(int j=0;j<prev.length()-1;j++){
if(prev.charAt(j)==prev.charAt(j+1)) count++;
else{
s+=String.valueOf(count)+prev.charAt(j);
count=1;
}
}
s+=String.valueOf(count)+prev.charAt(prev.length()-1);
i++;
prev="";
prev+=s;
}
return prev;
}
}