From 4eaf367faeb1a64bf35e851445b59c536ad5ee91 Mon Sep 17 00:00:00 2001 From: suyeun84 <81475092+suyeun84@users.noreply.github.com> Date: Sat, 11 Oct 2025 17:02:40 +0900 Subject: [PATCH] =?UTF-8?q?[20251011]=20PGM=20/=20LV2=20/=20=EB=A9=94?= =?UTF-8?q?=EB=89=B4=20=EB=A6=AC=EB=89=B4=EC=96=BC=20/=20=EA=B9=80?= =?UTF-8?q?=EC=88=98=EC=97=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...4 \353\246\254\353\211\264\354\226\274.md" | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 "suyeun84/202510/11 PGM LV2 \353\251\224\353\211\264 \353\246\254\353\211\264\354\226\274.md" diff --git "a/suyeun84/202510/11 PGM LV2 \353\251\224\353\211\264 \353\246\254\353\211\264\354\226\274.md" "b/suyeun84/202510/11 PGM LV2 \353\251\224\353\211\264 \353\246\254\353\211\264\354\226\274.md" new file mode 100644 index 00000000..0cf1d109 --- /dev/null +++ "b/suyeun84/202510/11 PGM LV2 \353\251\224\353\211\264 \353\246\254\353\211\264\354\226\274.md" @@ -0,0 +1,47 @@ +```java +import java.util.*; + +class Solution { + Map map; + int max = 0; + + public void dfs(String order, String key, int index, int end, int depth) { + if(depth == end) { + map.put(key, map.getOrDefault(key, 0) + 1); + max = Math.max(max, map.get(key)); + } + + for(int i = index + 1; i < order.length(); i++) { + dfs(order, key + order.charAt(i), i, end, depth + 1); + } + } + + public String[] solution(String[] orders, int[] course) { + ArrayList ans = new ArrayList<>(); + + for(int c : course) { + map = new HashMap<>(); + max = 0; + + for(String order: orders) { + char[] strs = order.toCharArray(); + Arrays.sort(strs); + order = new String(strs); + dfs(order, "", -1, c, 0); + } + + for(String key : map.keySet()) { + int value = map.get(key); + if(value > 1 && max == value) { + ans.add(key); + } + } + } + + Collections.sort(ans); + String[] answer = ans.toArray(new String[ans.size()]); + + return answer; + } +} +```