Leetcode Problem 1353. Maximum Number of Events That Can Be Attended
1353. Maximum Number of Events That Can Be Attended
Leetcode Solutions
Greedy Algorithm with Min Heap
Sort the events by their start time.
Initialize a min heap to keep track of ongoing events, sorted by their end time.
Iterate over each day within the range of the events.
For each day, do the following:
a. Add all events starting on this day to the min heap.
b. Remove all events from the min heap that have ended before this day.
c. If the min heap is not empty, attend the event that ends the earliest (top of the heap) and remove it from the heap.
d. Increment the count of attended events.
Continue until all events have been processed or the heap is empty.