Skip to content

Instantly share code, notes, and snippets.

@jonathanyee
Created January 27, 2014 02:02
Show Gist options
  • Save jonathanyee/8642244 to your computer and use it in GitHub Desktop.
Save jonathanyee/8642244 to your computer and use it in GitHub Desktop.
public static void combine( String str ){
int length = str.length();
char[] instr = str.toCharArray();
StringBuilder outstr = new StringBuilder();
doCombine( instr, outstr, length, 0 );
}
public static void doCombine( char[] instr, StringBuilder outstr, int length, int start ){
for( int i = start; i < length; i++ ){
outstr.append( instr[i] );
System.out.println( outstr );
if( i < length - 1 ){
doCombine( instr, outstr, length, i + 1 );
}
outstr.setLength(outstr.length() - 1);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment