From 9386b91c00071a3fe292f95e8807d8f55b73910f Mon Sep 17 00:00:00 2001 From: YANG YEEUN Date: Sat, 18 Jul 2026 02:06:34 +0900 Subject: [PATCH] =?UTF-8?q?=ED=98=B8=ED=85=94=20=EB=8C=80=EC=8B=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hotel_rent.java | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 hotel_rent.java diff --git a/hotel_rent.java b/hotel_rent.java new file mode 100644 index 0000000..23b3e9b --- /dev/null +++ b/hotel_rent.java @@ -0,0 +1,36 @@ +import java.util.*; +class Solution { + public int solution(String[][] book_time) { + PriorityQueue t_arr = new PriorityQueue<>((o1,o2)->o1[0]-o2[0]); + for(int i=0;i room = new PriorityQueue<>(); + int count = 0; + while(!t_arr.isEmpty()){ + int[] curr = t_arr.poll(); + if(room.isEmpty()){ + room.offer(curr[1]); + count++; + }else{ + int prev = room.peek(); + if(prev <= curr[0]){ + room.remove(prev); + room.offer(curr[1]); + }else{ + room.offer(curr[1]); + count++; + } + } + } + return count; + } +}