Skip to content

Instantly share code, notes, and snippets.

@tmosest
Created January 24, 2017 23:15
Show Gist options
  • Save tmosest/5a8aecbfac2784758f62b1e8108955dd to your computer and use it in GitHub Desktop.
Save tmosest/5a8aecbfac2784758f62b1e8108955dd to your computer and use it in GitHub Desktop.
Permutations of a String
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