From 49959385f028f954ff365109c2070491b8955160 Mon Sep 17 00:00:00 2001 From: lkhyun <102892446+lkhyun@users.noreply.github.com> Date: Mon, 3 Nov 2025 23:40:53 +0900 Subject: [PATCH] =?UTF-8?q?[20251103]=20PGM=20/=20Lv2=20/=20[1=EC=B0=A8]?= =?UTF-8?q?=20=EB=89=B4=EC=8A=A4=20=ED=81=B4=EB=9F=AC=EC=8A=A4=ED=84=B0?= =?UTF-8?q?=EB=A7=81=20/=20=EC=9D=B4=EA=B0=95=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...54\354\212\244\355\204\260\353\247\201.md" | 53 +++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 "lkhyun/202511/03 PGM Lv2 [1\354\260\250] \353\211\264\354\212\244 \355\201\264\353\237\254\354\212\244\355\204\260\353\247\201.md" diff --git "a/lkhyun/202511/03 PGM Lv2 [1\354\260\250] \353\211\264\354\212\244 \355\201\264\353\237\254\354\212\244\355\204\260\353\247\201.md" "b/lkhyun/202511/03 PGM Lv2 [1\354\260\250] \353\211\264\354\212\244 \355\201\264\353\237\254\354\212\244\355\204\260\353\247\201.md" new file mode 100644 index 00000000..05d896fb --- /dev/null +++ "b/lkhyun/202511/03 PGM Lv2 [1\354\260\250] \353\211\264\354\212\244 \355\201\264\353\237\254\354\212\244\355\204\260\353\247\201.md" @@ -0,0 +1,53 @@ +```java +import java.util.*; + +class Solution { + public int solution(String str1, String str2) { + List A = new ArrayList<>(); + List B = new ArrayList<>(); + + for(int i = 0; i + 1 < str1.length(); i++){ + String temp = str1.substring(i, i + 2); + if(!validation(temp.charAt(0)) || !validation(temp.charAt(1))) continue; + A.add(temp.toLowerCase()); + } + + for(int i = 0; i + 1 < str2.length(); i++){ + String temp = str2.substring(i, i + 2); + if(!validation(temp.charAt(0)) || !validation(temp.charAt(1))) continue; + B.add(temp.toLowerCase()); + } + + if(A.isEmpty() && B.isEmpty()) { + return 65536; + } + + Collections.sort(A); + Collections.sort(B); + + int intersection = 0; + int a = 0; + int b = 0; + while(a < A.size() && b < B.size()){ + int compare = A.get(a).compareTo(B.get(b)); + if(compare == 0){ + intersection++; + a++; + b++; + } else if(compare < 0){ + a++; + } else { + b++; + } + } + + int union = A.size() + B.size() - intersection; + + return (int)((double)intersection / union * 65536); + } + + public boolean validation(char c){ + return (c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z'); + } +} +```