Created
January 1, 2016 15:57
-
-
Save Wooking0310/ff34cff2520eee3e2d46 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 static void perm(String head, String input, int size, ArrayList<String> arr) throws Exception{ | |
// Random random = new Random(); | |
if (input.length() <= 1) { | |
arr.add(head+input); | |
// for(int i = 0; i < size; i++) { | |
// int num = random.nextInt(size-1)+1; | |
// System.out.println(arr.get(num)); | |
// arr.remove(num); | |
// size--; | |
return; | |
} | |
for (int i = 0; i < input.length(); i++) { | |
String newStr = input.substring(0, i) + input.substring(i + 1); // substring(자를 위치 첨자, 첨자에서 자를만큼의 길이) or substring(자를 위치 첨자) | |
perm(head + input.charAt(i), newStr, size, arr); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment