Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions Java/Big O/Example_12/Example.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package Example_12;

public class Example {

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));
}
}
}

public static void main(String[] args) {
Example ex = new Example();
ex.permutation("abcd");
}
}