We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 661079a commit 507a9e1Copy full SHA for 507a9e1
minjeong/Greedy/2024-09-29-[PGS]-#단속카메라.py
@@ -0,0 +1,19 @@
1
+import heapq
2
+
3
+def solution(routes):
4
+ routes.sort(key=lambda x:x[0])
5
6
+ answer = 0
7
+ h = [30001]
8
+ for r in routes:
9
+ earliestend = heapq.heappop(h)
10
+ if r[0] > earliestend:
11
+ answer += 1
12
+ h.clear()
13
+ else:
14
+ heapq.heappush(h, earliestend)
15
+ heapq.heappush(h, r[1])
16
17
+ if len(h) != 0:
18
19
+ return answer
0 commit comments