Skip to content

Instantly share code, notes, and snippets.

@Kaushal28
Created June 7, 2017 11:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Kaushal28/388fec36cd9252518f86f6249ba2b761 to your computer and use it in GitHub Desktop.
Save Kaushal28/388fec36cd9252518f86f6249ba2b761 to your computer and use it in GitHub Desktop.
public class noConsicutiveOnes{
public static int find(String s, int n){
if(s.length() == n){
return 1;
}
if(s.length() == 0 || s.charAt(s.length()-1) == '0'){
return find(s+"0", n) + find(s+"1",n);
}
return find(s+"0", n);
}
public static void main(String args[]){
System.out.println(find("", 10));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment