Created
January 24, 2017 23:15
-
-
Save tmosest/5a8aecbfac2784758f62b1e8108955dd to your computer and use it in GitHub Desktop.
Permutations of a String
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 void permutation(String str) | |
{ | |
permutation(str, ""); | |
} | |
public static permutation(String str, String prefix) | |
{ | |
if(str.length() == 0) | |
System.out.println(prefix); | |
else { | |
String rem = str.substring(0, i) + str.substring(i + 1); | |
permutation(rem, prefix + str.charAt(i)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment