Created
January 24, 2022 10:38
-
-
Save AnasAboreeda/40506821f8d1e6faaed1a183e754b6b7 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
class Permutation { | |
void permutation(String str) { | |
permutation(str, ""); | |
} | |
void permutation(String str, String prefix) { | |
if (str.length() == 0) { | |
System.out.println(prefix); | |
} else { | |
for (int i = 0; i < str.length(); i++) { | |
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