72 72 votes The following are the starting and ending times of activities $A, B, C, D, E, F, G$ and $H$ respectively in chronological order: $“a_s \: b_s \: c_s \: a_e \: d_s \: c_e \: e_s \: f_s \: b_e \: d_e \: g_s \: e_e \: f_e \: h_s \: g_e \: h_e”$. Here, $x_s$ denotes the starting time and $x_e$ denotes the ending time of activity X. We need to schedule the activities in a set of rooms available to us. An activity can be scheduled in a room only if the room is reserved for the activity for its entire duration. What is the minimum number of rooms required? $3$ $4$ $5$ $6$ Algorithms gatecse-2003 algorithms normal greedy-algorithms + – Kathleen 25.3k views answer comment Share Follow Print See all 13 Comments 13 13 Comments reply Show 10 previous comments Siddharth_Perkar commented Aug 18 reply Follow flag Here we need minimum 4 rooms at a given time as Maximum running count = minimum rooms. 0 0 replyShare Pranay_VG commented Aug 21 reply Follow flag Just apply the logic 0 0 replyShare Confused_Avi commented Sep 2 reply Follow flag Ans 4 0 0 replyShare Please log in or register to add a comment.
3 3 votes This type of problem can be solved by array representation of starting time ( taking +1) and ending time (taking -1 ) +1 +1 +1 -1 +1 -1 +1 +1 -1 -1 -1 -1 -1 -1 -1 -1 now taking sequence from array and sum them for getting largest positive no +1 +1 +1 -1 +1 -1 +1 +1 this array is 1st 8 sequences of original array and sum is 1+1+1-1+1-1+1+1=4 so ans is 4 Gate Ranker18 answered Apr 5, 2017 1 flag: ✌ Edit necessary (Sharad Kumar) Gate Ranker18 comment Share Follow See 1 comment 1 1 comment reply Chhotu commented Aug 3, 2017 i edited by Chhotu Oct 31, 2017 reply Follow flag @Gate Ranker18, Could you please provide some reference for this solution ? 0 0 replyShare Please log in or register to add a comment.
2 2 votes ans== 4 as we every new room is allocated when rest all allocated previously are filled ankur_mahiwal answered Jan 19, 2015 ankur_mahiwal comment Share Follow 0 reply Please log in or register to add a comment.
1 1 vote We can solve this by using Gantt chart also. Option (B) is right answer. Gaurav Yadav answered Jun 7, 2020 Gaurav Yadav comment Share Follow 0 reply Please log in or register to add a comment.
0 0 votes Now find chromatic number DeadMann answered Dec 20, 2023 DeadMann comment Share Follow 0 reply Please log in or register to add a comment.
0 0 votes this is a best and easiest apporoch for solving this quation Patel_And_Patel answered Nov 18, 2025 Patel_And_Patel comment Share Follow 0 reply Please log in or register to add a comment.
0 0 votes This problem can be solved using a simple timeline (parenthesis) approach. We plot the start and end time of each activity on a single time axis, where the start of an activity represents its entry into a room and the end represents leaving the room. An activity occupies a room for its entire duration, so if multiple activities overlap at the same time, they must be assigned to different rooms.By observing the diagram, we count how many activity lines overlap at any instant. The maximum overlap occurs when activities b, d, e, and f are running simultaneously, giving an overlap count of 4. Hence, the minimum number of rooms required to schedule all activities without conflict is 4.Final AnswerMinimum number of rooms required = 4 Ayansh_Dubey answered Jan 8 Ayansh_Dubey comment Share Follow 0 reply Please log in or register to add a comment.