Created
June 7, 2017 11:46
-
-
Save Kaushal28/388fec36cd9252518f86f6249ba2b761 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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