Skip to content

Instantly share code, notes, and snippets.

@orhanobut
Last active December 23, 2015 12:49
Show Gist options
  • Save orhanobut/6637881 to your computer and use it in GitHub Desktop.
Save orhanobut/6637881 to your computer and use it in GitHub Desktop.
Permutation of a given string Complexity = O(n!)
public static void permString(String p, String t){
int size = t.length();
if (size == 0){
System.out.println(p);
} else {
for (int i=0; i<size; i++){
perm(p + t.charAt(i),
t.substring(0,i) + t.substring(i+1));
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment