Hi everyone, I was taking up a challenge in 'hackerrank'. I build a solution and when i submitted the code, the first 7 Test cases of the site is getting passed and the next 3 test are failing saying "Wrong Answer". I'm sure, where the solution is wrong .
Algorithm I Used for the Problem:
1) get the No. of Busy slots.
2) Get the Starting and ending time into an array.
3) arrange them in ascending order based on the 'Starting time of the Meeting'.
4)add 1 slot in the beginning of the array: to mark the start of the day. Likewise, add a slot in the end of the array to mark the end of the day.
5) Combine 2 meetings, if they are overlapping.
6) find the time slot available between each meeting and compare with the Given 'time slot'.
7) if the 'Time slot' fits, print them.
Below is the problem: Given M busy-time slots of N people, You need to print all the available time slots when all the N people can schedule a meeting for a duration of K minutes.
Event time will be of form HH MM ( where 0 <= HH <= 23 and 0 <= MM <= 59 ), K will be in the form minutes.
M K [ M number of busy time slots , K is the duration in minutes ]
Followed by M lines with 4 numbers on each line.
Each line will be of form StartHH StartMM EndHH EndMM [ Example 9Am-11Am time slot will be given as 9 00 11 00 ]
An event time slot is of form [Start Time, End Time ) . Which means it inclusive at start time but doesn’t include the end time.
So an event of form 10 00 11 00 => implies that the meeting start at 10:00 and ends at 11:00, so another meeting can start at 11:00.