diff --git "a/LiiNi-coder/202507/23 BOJ \354\225\240\353\204\210\352\267\270\353\236\250.md" "b/LiiNi-coder/202507/23 BOJ \354\225\240\353\204\210\352\267\270\353\236\250.md" new file mode 100644 index 00000000..657a3174 --- /dev/null +++ "b/LiiNi-coder/202507/23 BOJ \354\225\240\353\204\210\352\267\270\353\236\250.md" @@ -0,0 +1,52 @@ +```java +import java.io.BufferedReader; +import java.io.InputStreamReader; +import java.io.IOException; +import java.util.Arrays; + +public class Main { + private static BufferedReader br; + private static int[] charCount; // 각 문자 a~z의 개수 + private static char[] inputChars; + private static char[] output; + private static int length; + private static StringBuilder sb; + + public static void main(String[] args) throws IOException { + br = new BufferedReader(new InputStreamReader(System.in)); + int t = Integer.parseInt(br.readLine()); + sb = new StringBuilder(); + + for (int testCase = 0; testCase < t; testCase++) { + inputChars = br.readLine().toCharArray(); + Arrays.sort(inputChars); + length = inputChars.length; + output = new char[length]; + charCount = new int[26]; + + for (char c : inputChars) { + charCount[c - 'a']++; + } + + permute(0); + } + System.out.print(sb); + } + + private static void permute(int depth) { + if (depth == length) { + sb.append(output).append('\n'); + return; + } + + for (int i = 0; i < 26; i++) { + if (charCount[i] > 0) { + output[depth] = (char) ('a' + i); + charCount[i]--; + permute(depth + 1); + charCount[i]++; + } + } + } +} +```