You want to send some messages of various lengths (specified in the number
of minutes it takes to send them), and don't want more than three of them
to be completely intercepted. A message is considered to be intercepted if some
malevolent person taps your connection the whole time the message is being sent (a partially
tapped message won't do this person any good). Assuming that the connection is being tapped during
interceptTime consecutive minutes, what's the shortest time you need to send all the messages
so at most three of the messages can be completely intercepted?
Each message is sent in one continuous transmission, though any number of messages can
be sent in parallel. You can only start sending a message at the beginning of a minute.
The messages can be sent in any order.
Create a class ShortTaps containing the method leastTime which takes an int interceptTime
and a int[] messageTimes (containing the time in minutes it takes to send each message,
respectively) and returns an int, the minimum time needed to send all the messages so that
at most three of them can be intercepted.
|