作者DJYOSHITAKA (franchouchouISBEST)
標題Re: [閒聊] 每日leetcode
時間2025-07-07 13:45:48
遭遇了前所未有的苦戰
幹==
好想跳出去當風箏
def maxEvents(self, events: List[List[int]]) -> int:
pq = []
events.sort()
idx, ans = 0, 0
for i in range(100001):
while idx<len(events) and events[idx][0]<=i:
heappush(pq, events[idx][1])
idx += 1
while pq and pq[0]<i:
heappop(pq)
if pq:
heappop(pq)
ans += 1
return ans
--
https://i.imgur.com/wRnmv7s.jpeg
https://i.imgur.com/mceoqQj.jpeg
--
※ 發信站: 批踢踢實業坊(www.ptt-club.com.tw), 來自: 220.132.58.28 (臺灣)
※ 文章網址: https://www.ptt-club.com.tw/Marginalman/M.1751867153.A.980