You are on page 1of 4

A Movie Multiplex

There is a hypothetical movie multiplex that can run shows throughout the day from
00:00 to 23:59 hours with a limited capacity of shows at a time.
Implement the following functions for the multiplex.

Function Arguments Return Function Description


type

setCapacity int capacity int This function sets the number


of shows the multiplex can
have simultaneously by taking
the value as an argument and
returns 1 after successfully
setting the capacity.

scheduleShow string int It has three string parameters


movieName,string giving the movie name, start
startTime, string time and end time of a show.
endTime The start and end time string
will be in “HH:MM” format.
This function allots the slot to
the show and returns the
length of the show in minutes
after successful allocation and
returns -1 if it is not possible to
allot the required time slot.
Note: All the events will
happen within the same day
and won't go till the next day.

cancelShow string int It has three string parameters


movieName,string giving the movie name, start
startTime, string time and end time of a show.
endTime The start and end time string
will be in “HH:MM” format.
This function cancels the slot
of the show and returns the
length of the canceled show
after successful cancellation.
Note: Only the shows that have
been scheduled before will
only be given to cancel in this
function.
getEmptySlots void int This function returns the
number of slots throughout the
day where no movie show is
going on.

getMaxEmptySlot void int This function returns the


longest slot in minutes among
all of the empty slots in the
day.

getSlotAtleastX int X string This function takes an integer


argument X.
It then returns the earliest start
time of an empty slot that is at
least X minutes long.
Return empty string if no such
slot is present.

maxShowsSimult void int This function returns the


aneously maximum number of shows
that are running simultaneously
at any point throughout the
day.

movieWithMostS void int This function returns the name


hows of the movie which got the
most shows. If 2 movies have
same number of shows, it
returns the lexicographically
smaller movie name

TestCases:

Test Case Test Case Input Expecte Explanation


Description d
Output

testZero Set capacity capacity = 3 1 Sets the capacity of


the multiplex to 3 i.e,
it can have 3 shows
simultaneously at
maximum.

testOne Schedule a show movieName = 73 The asked time slot


“Abc” is allotted and the
startTime = movie length is 73
“12:49”
endTime =
“14:01”

testTwo Schedule a show movieName = 133 The asked time slot


“Def” is allotted and the
startTime = movie length is 133
“13:49”
endTime =
“15:01”

testThree Find number of void 2 There are 2


empty slots completely empty
slots, one from
“00:00” to “12:48”
and the other from
“15:02” to “23:59”

testFour Find max length void 769 Slot from “00:00” to


empty slot “12:48” is the longest
empty slot which is
769 minutes long.

testFive Find the earliest X = 65 00:00 From “00:00” to


slot of length at “12:48” is the earliest
least X minutes slot that is at least 65
minutes long.

testSix Find maximum void 2 From “13:49” to


number of shows “14:01” there are 2
running shows happening
simultaneously simultaneously in the
multiplex.

testSeven Schedule a show movieName = 61 The asked time slot


“Ghi” is allotted and the
startTime = movie length is 61
“13:00”
endTime =
“14:00”

testEight Schedule a show movieName = -1 The shows were


“Def” running at max
startTime = capacity at the time
“14:00” of the asked slot. So
endTime = the slot was not
“15:00” alloted

testNine Find maximum void 3 From “13:49” to


number of shows “14:00” there are 3
running shows happening
simultaneously simultaneously at the
multiplex.

testTen Cancel a show movieName = 61 The requested movie


“Ghi” slot was canceled
startTime = and its length was 61
“13:00” minutes.
endTime =
“14:00”

testEleven Schedule a show movieName = 601 The asked time slot


“Jkf” is allotted and the
startTime = movie length is 601
“01:00”
endTime =
“11:00”

testTwelve Schedule a show movieName = 361 The asked time slot


“Aab” is allotted and the
startTime = movie length is 361
“15:00”
endTime =
“21:00”

testThirteen Find the earliest 120 21:01 The earliest free slot
slot of length at for 120 minutes
least X minutes starts from “21:01”

testFourtee Find the movie void Aab “Aab” is the


n with most shows lexicographically
smallest movie with
the most number of
shows.

You might also like