imashutosh51

N meetings in one room

Feb 7th, 2026
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.78 KB | None | 0 0
  1. '''
  2. You want the meetings to end as quickly as possible so that you can allot the more meetings.
  3. Always take the meeting with the earliest finishing time that doesn’t overlap.
  4. '''
  5. class Solution:
  6.    
  7.     #Function to find the maximum number of meetings that can
  8.     #be performed in a meeting room.
  9.     def maximumMeetings(self,start,end):
  10.         arr=[]
  11.         for i in range(len(start)):
  12.             arr.append([end[i],start[i]]) #sort in increasing order as per the end time
  13.         arr.sort()
  14.         ans=0
  15.         prev_finish=-1
  16.         for i in arr:
  17.             if i[1]>prev_finish: # if current meeting start time is afte the end time of the previous meeting, consider this meeting
  18.                 ans+=1
  19.                 prev_finish=i[0]
  20.         return ans
  21.            
Advertisement
Add Comment
Please, Sign In to add comment