From 161cd4df87d9cc8141f4b4f6332657eeed9e378e Mon Sep 17 00:00:00 2001 From: Jeongha Park <162397816+mirupio@users.noreply.github.com> Date: Tue, 1 Sep 2026 14:10:52 +0900 Subject: [PATCH 1/5] =?UTF-8?q?=ED=94=84=EB=A1=9C=EA=B7=B8=EB=9E=98?= =?UTF-8?q?=EB=A8=B8=EC=8A=A460060=20-=20=EA=B0=80=EC=82=AC=20=EA=B2=80?= =?UTF-8?q?=EC=83=89=20->=20hashmap=20=EB=AF=B8=EB=A6=AC=20=EC=A0=80?= =?UTF-8?q?=EC=9E=A5=20(=EB=A9=94=EB=AA=A8=EB=A6=AC=20=EC=B4=88=EA=B3=BC)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gilbut/ch11_datastructure/Q60060.java | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 src/programmers/gilbut/ch11_datastructure/Q60060.java diff --git a/src/programmers/gilbut/ch11_datastructure/Q60060.java b/src/programmers/gilbut/ch11_datastructure/Q60060.java new file mode 100644 index 0000000..54f5081 --- /dev/null +++ b/src/programmers/gilbut/ch11_datastructure/Q60060.java @@ -0,0 +1,44 @@ +package programmers.gilbut.ch11_datastructure; + +import java.util.*; + +// 메모리 초과 +class Q60060 { + public int[] solution(String[] words, String[] queries) { + int[] answer = new int[queries.length]; + + HashMap map = new HashMap<>(); + for(String word: words){ + for(int i=0;i Date: Tue, 1 Sep 2026 14:11:09 +0900 Subject: [PATCH 2/5] =?UTF-8?q?=ED=94=84=EB=A1=9C=EA=B7=B8=EB=9E=98?= =?UTF-8?q?=EB=A8=B8=EC=8A=A460060=20-=20=EA=B0=80=EC=82=AC=20=EA=B2=80?= =?UTF-8?q?=EC=83=89=20->=20=EA=B8=B8=EC=9D=B4=EB=B3=84=20=EC=A0=95?= =?UTF-8?q?=EB=A0=AC=20+=20=EC=9D=B4=EB=B6=84=20=ED=83=90=EC=83=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gilbut/ch11_datastructure/Q60060_2.java | 102 ++++++++++++++++++ 1 file changed, 102 insertions(+) create mode 100644 src/programmers/gilbut/ch11_datastructure/Q60060_2.java diff --git a/src/programmers/gilbut/ch11_datastructure/Q60060_2.java b/src/programmers/gilbut/ch11_datastructure/Q60060_2.java new file mode 100644 index 0000000..8a92c75 --- /dev/null +++ b/src/programmers/gilbut/ch11_datastructure/Q60060_2.java @@ -0,0 +1,102 @@ +package programmers.gilbut.ch11_datastructure; + +import java.util.*; + +class Q60060_2 { + + HashMap> map = new HashMap<>(); + HashMap> reverseMap = new HashMap<>(); + + public int[] solution(String[] words, String[] queries) { + int[] answer = new int[queries.length]; + + // 길이별로 단어 저장 + for(String word: words){ + int len = word.length(); + + map.computeIfAbsent(len, k->new ArrayList<>()) + .add(word); + + String reverseWord = new StringBuilder(word).reverse().toString(); + reverseMap.computeIfAbsent(len, k->new ArrayList<>()) + .add(reverseWord); + } + + // 길이별 정렬 + for(List list: map.values()){ + Collections.sort(list); + } + for(List list: reverseMap.values()){ + Collections.sort(list); + } + + for(int i=0;i list; + + // 접두사일 경우 + if(query.charAt(0) == '?'){ + query = new StringBuilder(query).reverse().toString(); + list = reverseMap.get(len); + } + // 접미사일 경우 + else{ + list = map.get(len); + } + + if(list == null){ + answer[i] = 0; + continue; + } + + String min = query.replace('?','a'); + String max = query.replace('?','z'); + + int start = lowerBound(list,min); + int end = upperBound(list,max); + + answer[i] = end-start; + } + + return answer; + } + + // target 이상이 처음 나오는 위치 + int lowerBound(List list, String target){ + int left = 0; + int right = list.size()-1; + + while(left<=right){ + int mid = (left+right)/2; + + if(list.get(mid).compareTo(target)>=0){ + right = mid-1; + } + else{ + left = mid+1; + } + } + + return left; + } + // target 초과가 처음 나오는 위치 + int upperBound(List list, String target){ + int left = 0; + int right = list.size()-1; + + while(left<=right){ + int mid = (left+right)/2; + + if(list.get(mid).compareTo(target)>0){ + right = mid-1; + } + else{ + left = mid+1; + } + } + + return left; + } +} \ No newline at end of file From 106436f36d139984442c794a8a0b156d14c977fd Mon Sep 17 00:00:00 2001 From: Jeongha Park <162397816+mirupio@users.noreply.github.com> Date: Tue, 1 Sep 2026 15:03:28 +0900 Subject: [PATCH 3/5] =?UTF-8?q?=ED=94=84=EB=A1=9C=EA=B7=B8=EB=9E=98?= =?UTF-8?q?=EB=A8=B8=EC=8A=A442884=20-=20=EB=8B=A8=EC=86=8D=EC=B9=B4?= =?UTF-8?q?=EB=A9=94=EB=9D=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gilbut/ch11_datastructure/Q42884.java | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 src/programmers/gilbut/ch11_datastructure/Q42884.java diff --git a/src/programmers/gilbut/ch11_datastructure/Q42884.java b/src/programmers/gilbut/ch11_datastructure/Q42884.java new file mode 100644 index 0000000..39066c1 --- /dev/null +++ b/src/programmers/gilbut/ch11_datastructure/Q42884.java @@ -0,0 +1,35 @@ +package programmers.gilbut.ch11_datastructure; + +import java.util.*; + +class Q42884 { + public int solution(int[][] routes) { + int answer = 0; + + Arrays.sort(routes,(a,b)->a[0]-b[0]); + + int count = 1; + int s1 = routes[0][0]; // -20 + int e1 = routes[0][1]; // -15 + for(int i=1;i Date: Tue, 1 Sep 2026 15:12:11 +0900 Subject: [PATCH 4/5] =?UTF-8?q?=ED=8C=8C=EC=9D=BC=20=EC=9D=B4=EB=8F=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../{ch11_datastructure => ch12_implementation}/Q42884.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename src/programmers/gilbut/{ch11_datastructure => ch12_implementation}/Q42884.java (93%) diff --git a/src/programmers/gilbut/ch11_datastructure/Q42884.java b/src/programmers/gilbut/ch12_implementation/Q42884.java similarity index 93% rename from src/programmers/gilbut/ch11_datastructure/Q42884.java rename to src/programmers/gilbut/ch12_implementation/Q42884.java index 39066c1..7b76436 100644 --- a/src/programmers/gilbut/ch11_datastructure/Q42884.java +++ b/src/programmers/gilbut/ch12_implementation/Q42884.java @@ -1,4 +1,4 @@ -package programmers.gilbut.ch11_datastructure; +package programmers.gilbut.ch12_implementation; import java.util.*; From eef36b8efcce0980c0e3229bec2599cc6fcae422 Mon Sep 17 00:00:00 2001 From: Jeongha Park <162397816+mirupio@users.noreply.github.com> Date: Tue, 1 Sep 2026 16:52:48 +0900 Subject: [PATCH 5/5] =?UTF-8?q?=ED=94=84=EB=A1=9C=EA=B7=B8=EB=9E=98?= =?UTF-8?q?=EB=A8=B8=EC=8A=A492342=20-=20=EC=96=91=EA=B6=81=EB=8C=80?= =?UTF-8?q?=ED=9A=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/programmers/gilbut/ch13_kakao/Q92342.java | 74 +++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 src/programmers/gilbut/ch13_kakao/Q92342.java diff --git a/src/programmers/gilbut/ch13_kakao/Q92342.java b/src/programmers/gilbut/ch13_kakao/Q92342.java new file mode 100644 index 0000000..ed499f7 --- /dev/null +++ b/src/programmers/gilbut/ch13_kakao/Q92342.java @@ -0,0 +1,74 @@ +package programmers.gilbut.ch13_kakao; + +class Q92342 { + static int N; + static int[] Info; + static int max; + static int[] answer = new int[11]; + public int[] solution(int n, int[] info) { + N = n; + Info = info; + max = Integer.MIN_VALUE; + + int[] lion = new int[11]; + dfs(0,0,lion); + + if(max == Integer.MIN_VALUE){ + return new int[]{-1}; + } + return answer; + } + + static void dfs(int index, int count, int[] lion){ + if(count > N){ + return; + } + if(index == 11){ + // 화살 남은거 다 0점에 몰아줌 + lion[10] += N-count; + + int apeachGrade = 0; + int lionGrade = 0; + for(int j=0;j<10;j++){ + if(Info[j] >= lion[j] && Info[j] != 0){ + apeachGrade += 10-j; + } + else if(Info[j] < lion[j]){ + lionGrade += 10-j; + } + } + + int diff = lionGrade-apeachGrade; + if(diff>0){ + // 점수차 더 큰거 + if(diff>max){ + max = diff; + answer = lion.clone(); + } + + // 점수차 같으면 낮은 점수가 더 많은 거 + else if(diff==max){ + for(int i=10;i>=0;i--){ + if(lion[i] > answer[i]){ + answer = lion.clone(); + break; + } + else if(lion[i] < answer[i]){ + break; + } + } + } + } + + return; + } + + // 라이언 승 + lion[index] = Info[index]+1; + dfs(index+1,count+lion[index],lion); + + // 라이언 포기 + lion[index] = 0; + dfs(index+1,count,lion); + } +} \ No newline at end of file