Skip to content

Instantly share code, notes, and snippets.

@TabsPH
Created November 2, 2012 07:03
Show Gist options
  • Save TabsPH/3999175 to your computer and use it in GitHub Desktop.
Save TabsPH/3999175 to your computer and use it in GitHub Desktop.
String Permutation
public class Anagram {
public static void main(String[] args) {
performedPermutation( "", "Java" );
}
public static void performedPermutation( String start, String end ) {
if( end.length() == 0 )
System.out.println( start.concat( end ) );
else {
for( int i=0; i<end.length(); i++ ){
String tmp = end.substring( 0, i ) + end.substring( i+1 );
performedPermutation( start + end.charAt(i), tmp );
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment