Created
May 16, 2017 08:10
-
-
Save Ipseeta/d8c5138867cf2617f5da107b97c9254e to your computer and use it in GitHub Desktop.
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 class StringPermutation { | |
public static void main(String[] args) { | |
perm("123"); | |
} | |
private static void perm(String str){ | |
perm("",str); | |
} | |
private static void perm(String prefix, String str) { | |
if(null!=str){ | |
int n = str.length(); | |
if(n == 0) System.out.println(prefix); | |
else{ | |
for(int i=0;i<n;i++){ | |
perm(prefix + str.charAt(i), str.substring(0, i)+str.substring(i+1, n)); | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment