import java.util.Arrays;
import java.util.Scanner;
public class Main {
public static void permut(String s, String ans) {
String news="";
if(news.length()==s.length()) {
System.out.println(ans);
return;
}
for(int i=0;i<s.length();i++){
char curr=s.charAt(i);
news =s.substring(0,i) + s.substring(i+1);
permut(news,ans+curr);
}
}
public static void main(String[] args) {
String s="abc";
permut(s,"");
}
}
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter