• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

hackerrank: Meeting Schedules Problem: only first 7 Test cases are passing. next 3 are failing

 
Ranch Hand
Posts: 36
Eclipse IDE Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.

Input Format:

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.

Sample Input:
5 120
16 00 17 00
10 30 14 30
20 45 22 15
10 00 13 15
09 00 11 00

Sample Output:
00 00 09 00
17 00 20 45

Sample Input:
8 60
08 00 10 15
22 00 23 15
17 00 19 00
07 00 09 45
09 00 13 00
16 00 17 45
12 00 13 30
11 30 12 30

Sample Output:
00 00 07 00
13 30 16 00
19 00 22 00

Constraints :
1 <= M <= 100

Note: 24 00 has to be presented as 00 00.




Kindly, let me know, what is wrong ?

Paul
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic