From eb8d0ff5e40a8219155f9fc89bff33dca1bf710e Mon Sep 17 00:00:00 2001 From: suyeun84 <81475092+suyeun84@users.noreply.github.com> Date: Sat, 6 Sep 2025 17:09:39 +0900 Subject: [PATCH] =?UTF-8?q?[20250906]=20PGM=20/=20LV3=20/=20=EB=B6=88?= =?UTF-8?q?=EB=9F=89=20=EC=82=AC=EC=9A=A9=EC=9E=90=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 --- ...1 \354\202\254\354\232\251\354\236\220.md" | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 "suyeun84/202509/06 PGM LV3 \353\266\210\353\237\211 \354\202\254\354\232\251\354\236\220.md" diff --git "a/suyeun84/202509/06 PGM LV3 \353\266\210\353\237\211 \354\202\254\354\232\251\354\236\220.md" "b/suyeun84/202509/06 PGM LV3 \353\266\210\353\237\211 \354\202\254\354\232\251\354\236\220.md" new file mode 100644 index 00000000..29e50d95 --- /dev/null +++ "b/suyeun84/202509/06 PGM LV3 \353\266\210\353\237\211 \354\202\254\354\232\251\354\236\220.md" @@ -0,0 +1,37 @@ +```java +import java.util.*; +class Solution { + public int solution(String[] user_id, String[] banned_id) { + HashSet> result = new HashSet<>(); + + dfs(new HashSet<>(), user_id, banned_id, result); + return result.size(); + } + + private void dfs(HashSet hashset, String[] user_id, String[] banned_id, HashSet> result) { + if (hashset.size() == banned_id.length) { + result.add(new HashSet<>(hashset)); + return; + }; + String target = banned_id[hashset.size()]; + + for (String user : user_id) { + if (hashset.contains(user)) continue; + if (check(target, user)) { + hashset.add(user); + dfs(hashset, user_id, banned_id, result); + hashset.remove(user); + } + } + } + private boolean check(String target, String user) { + if (target.length() != user.length()) return false; + for (int j = 0; j < target.length(); j++) { + if (target.charAt(j) == ('*')) continue; + if (target.charAt(j) == user.charAt(j)) continue; + return false; + } + return true; + } +} +```