From bb6d3b2ded2c447b427f884e2604ffc7434b2a8c Mon Sep 17 00:00:00 2001 From: 724thomas <724thomas@gmail.com> Date: Wed, 27 Aug 2025 10:28:51 +0900 Subject: [PATCH] =?UTF-8?q?[=EC=B5=9C=EC=9B=90=EC=A4=80]=20Day03?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Q2824.java" | 29 ++++++++++++ .../Q1353.java" | 46 +++++++++++++++++++ 2 files changed, 75 insertions(+) create mode 100644 "leetcode2/1easy/\354\265\234\354\233\220\354\244\200/Q2824.java" create mode 100644 "leetcode2/2medium/\354\265\234\354\233\220\354\244\200/Q1353.java" diff --git "a/leetcode2/1easy/\354\265\234\354\233\220\354\244\200/Q2824.java" "b/leetcode2/1easy/\354\265\234\354\233\220\354\244\200/Q2824.java" new file mode 100644 index 00000000..04ff0a1b --- /dev/null +++ "b/leetcode2/1easy/\354\265\234\354\233\220\354\244\200/Q2824.java" @@ -0,0 +1,29 @@ +package Leetcode.최원준; + +/* +1. 아이디어 : + + +2. 시간복잡도 : +O( ) + +3. 자료구조/알고리즘 : + + */ + +import java.util.List; + +public class Q2824 { + class Solution { + public int countPairs(List nums, int target) { + int ans = 0, n = nums.size(); + for (int i=0; i pq = new PriorityQueue<>(); + int removed = 0; + int day = 0; + int ans = 0; + int idx = 0; + Arrays.sort(events, (a, b) -> a[0]-b[0]); + while (removed < events.length) { + while (idx < n && events[idx][0] <= day) { + pq.add(events[idx++][1]); + } + + while (!pq.isEmpty() && pq.peek() < day) { + pq.poll(); + removed++; + } + if (!pq.isEmpty()) { + ans++; + pq.poll(); + removed++; + } + day++; + } + return ans; + } + } +}