From a687ea77f18fdd908af6550b89456603e73000d1 Mon Sep 17 00:00:00 2001 From: SinnoLn Date: Mon, 26 Oct 2026 12:54:00 +0900 Subject: [PATCH 1/3] 4074. Maximum Product Pair With Target Sum --- ...Maximum Product Pair With Target Sum.java" | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 "leetcode3/\354\235\264\354\247\204\355\235\254/4074. Maximum Product Pair With Target Sum.java" diff --git "a/leetcode3/\354\235\264\354\247\204\355\235\254/4074. Maximum Product Pair With Target Sum.java" "b/leetcode3/\354\235\264\354\247\204\355\235\254/4074. Maximum Product Pair With Target Sum.java" new file mode 100644 index 00000000..6c6fc96d --- /dev/null +++ "b/leetcode3/\354\235\264\354\247\204\355\235\254/4074. Maximum Product Pair With Target Sum.java" @@ -0,0 +1,44 @@ +/* + +1. 아이디어 : 조건을 만족하는 원소쌍중 가장 큰 값 구하기 + i,j의 순서는 더 큰 원소 idx가 먼저와야함을 명심 + +2. 시간복잡도 : O(N^2) + +3. 자료구조/알고리즘 : 완전탐색 + + */ + + +class Solution { + public int[] maxProductPair(int[] nums, int target) { + // 조건을 만족하는 모든 pair중 nums[i] * nums[j]이 가장 큰 값 + // 없으면 [-1, -1] + + int[] ans = {-1, -1}; + int maxVal = Integer.MIN_VALUE; + + for(int i=0; i maxVal) { + maxVal = jVal*iVal; + + if(jVal>iVal) { + ans[0] = j; + ans[1] = i; + } + else { + ans[0] = i; + ans[1] = j; + } + } + } + } + + return ans; + } +} \ No newline at end of file From 7e5302aaef683a21fa0a7646d60e8c3c4fb1dfe9 Mon Sep 17 00:00:00 2001 From: SinnoLn Date: Mon, 26 Oct 2026 12:57:13 +0900 Subject: [PATCH 2/3] 2136. Earliest Possible Day of Full Bloom --- ... Earliest Possible Day of Full Bloom.java" | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 "leetcode3/\354\235\264\354\247\204\355\235\254/2136. Earliest Possible Day of Full Bloom.java" diff --git "a/leetcode3/\354\235\264\354\247\204\355\235\254/2136. Earliest Possible Day of Full Bloom.java" "b/leetcode3/\354\235\264\354\247\204\355\235\254/2136. Earliest Possible Day of Full Bloom.java" new file mode 100644 index 00000000..1c1b0ccf --- /dev/null +++ "b/leetcode3/\354\235\264\354\247\204\355\235\254/2136. Earliest Possible Day of Full Bloom.java" @@ -0,0 +1,40 @@ +/* +1. 아이디어: + - 모든 꽃을 피우는 가장 짧은 일 수 계산 + - 꽃을 심는 기간동안 다른 꽃을 같이 심을수 없다. + - 그러므로 plantTime은 고정되고 growTime에 따라 기간이 결정 + - growTime이 길수록 먼저 심는게 유리하므로 growTime이 높은순으로 정렬 후 값을 계산한다 + +2. 시간복잡도: O(N) + +3. 자료구조/알고리즘: 그리디 +*/ + +class Solution { + public int earliestFullBloom(int[] plantTime, int[] growTime) { + // 1. 꽃을 심는 작업은 겹칠 수 없다 + // 2. 꽃은 growTime+1에 핀다 + // 3. 꽃을 나눠 심어도 된다 + + List flowers = new ArrayList<>(); + + for(int i=0; i Integer.compare(b[1],a[1])); + + int allBloomingPeriod = flowers.get(0)[0]; + int nextBlooming = flowers.get(0)[1]+1; + + for(int i=1; i Date: Mon, 26 Oct 2026 19:21:42 +0900 Subject: [PATCH 3/3] 3613. Minimize Maximum Component Cost --- ...613. Minimize Maximum Component Cost.java" | 61 +++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 "leetcode3/\354\235\264\354\247\204\355\235\254/3613. Minimize Maximum Component Cost.java" diff --git "a/leetcode3/\354\235\264\354\247\204\355\235\254/3613. Minimize Maximum Component Cost.java" "b/leetcode3/\354\235\264\354\247\204\355\235\254/3613. Minimize Maximum Component Cost.java" new file mode 100644 index 00000000..30331c9b --- /dev/null +++ "b/leetcode3/\354\235\264\354\247\204\355\235\254/3613. Minimize Maximum Component Cost.java" @@ -0,0 +1,61 @@ +/* + +1. 아이디어 : +- 그래프에서 k개의 컴포넌트를 남기기 위한 최소 비용 구하기 +- 간선 비용 오름차순 정렬 후, 비용이 작은 간선부터 순서대로 연결 +- Union-Find를 통해 두 노드를 연결할 때마다 연결(간선) 수를 증가시키며, n-k개 연결 시점의 가중치 반환 + +2. 시간복잡도 : O(E log E) + +3. 자료구조/알고리즘 : 크루스칼 알고리즘 (Union-Find) + + */ + +class Solution { + private int[] parent; + public int minCost(int n, int[][] edges, int k) { + + if(edges.length == 0) return 0; + + // 가중치 기준 오름차순 정렬 + Arrays.sort(edges, (a,b) -> Integer.compare(a[2],b[2])); + + parent = new int[n]; + Arrays.fill(parent, -1); + + int link = 0; + + for(int i=0; i parent[rootY]) parent[rootX] = rootY; + else if(parent[rootX] < parent[rootY]) parent[rootY] = rootX; + else { + parent[rootX] = rootY; + parent[rootY]--; + } + + return true; + } +} \ No newline at end of file