Advertisement
Guest User

Untitled

a guest
May 27th, 2016
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.38 KB | None | 0 0
  1. public static void perm(String s) {
  2. alternativePerm("", s);
  3. }
  4.  
  5. public static void alternativePerm(String prefix, String s) {
  6. if (s.length() == 0) {
  7. System.out.println(prefix);
  8. }
  9. for (int i=0; i<s.length(); i++) {
  10. alternativePerm(prefix+s.charAt(i), s.substring(0,i) + s.substring(i+1, s.length()));
  11. }
  12. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement