Last active
December 23, 2015 12:49
-
-
Save orhanobut/6637881 to your computer and use it in GitHub Desktop.
Permutation of a given string
Complexity = O(n!)
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 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