Created
February 15, 2015 14:00
-
-
Save azeemmohd/72435943f826b398d51a to your computer and use it in GitHub Desktop.
This file contains 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 static String doStuff(int n, int j, int k) { | |
String s = formN(n); | |
return s.substring(j, k+1); | |
} | |
private static String formN(int n) { | |
StringBuilder sb = new StringBuilder(""); | |
for(int i = 0; i<=n; i++){ | |
sb.append(Integer.toBinaryString(i)); | |
} | |
return sb.toString(); | |
} | |
public static void main(String [] args) { | |
System.out.println(doStuff(5, 3, 6)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment