Back to course home
0% completed
Vote For New Content
Simple solution without heap
Mohammed Dh Abbas
Jul 16, 2024
import heapq #class Meeting: # def __init__(self, start, end): # self.start = start # self.end = end # You can override/modify __lt__ as per your need #setattr(Meeting, "__lt__", lambda self, other: write logic here) class Solution: def findMinimumMeetingRooms(self, meetings): meetings.sort(key = lambda x: x.start) min_rooms = 1 def do_overlap(a, b): return b.start < a.end overlap_found = False for i in range(1, len(meetings)): if overlap_found and not do_overlap(meetings[i - 1], meetings[i]): overlap_found = False # Count the overlap only once so we need the overlap_found for that elif not overlap_found and do_overlap(meetings[i - 1], meetings[i]): min_rooms += 1 overlap_found = True return min_rooms
0
0
Comments
Comments
D
dharm.kr16 a year ago
This code gives minRooms required as 3 for testcase [[2, 4], [3, 5], [6, 12], [7, 15]] but correct answer is 2
On this page