Problem Statement
PROBLEM STATEMENT
A relay race has a different person running each lap. After each lap is
complete, the judge records the total elapsed time since the race started
(since the first person started running). Each of these times is written in
the following format: "HH:MM:SS.SSSS" (quotes for clarity only) - where HH
represents the two digit hours, MM represents the two digit minutes, and
SS.SSSS represents the two digit seconds followed by 4 decimal places of
fractional seconds.
Create a class RelayRace that contains the method fastest, which takes a
String[] times and returns the fastest individual lap time in the above format.
DEFINITION
Class: RelayRace
Method: fastest
Parameters: String[]
Returns: String
Method signature (be sure your method is public): String fastest(String[]
times);
NOTES
- Each entry represents the time elapsed since the beginning of the race - so
to get the time of just one specific lap (other than the first lap), you will
need to subtract the time from the previous lap.
TopCoder will ensure the validity of the inputs. Inputs are valid if all of
the following criteria are met:
- times will contain between 1 and 50 elements, inclusive.
- each element in times will be in the form of "HH:MM:SS.SSSS" (quotes for
clarity only) - where HH is between 00 and 99, MM is between 00 and 59, and
SS.SSSS is between 00.0000 and 59.9999 - all ranges inclusive.
- no element in times will represent an earlier time than an element before it
(though two might represent the same time - indicating a lap that took zero
time).
EXAMPLES
In the following examples, quotes, commas and braces are for clarity only.
They are never part of the input or output.
(1)
times = times = {"00:00:20.0000","00:00:30.0000","00:00:50.0000"}
returns: "00:00:10.0000"
This is the second runner's time.
(2)
times = {"00:00:20.0000","00:00:30.0000"}
returns: "00:00:10.0000"
This is the second runner's time.
(3)
times = {"00:00:20.0000"}
returns: "00:00:20.0000"
There is only one runner - so he/she is the fastest.
(3)
times = {"80:00:00.0001","90:00:00.0000"}
returns: "09:59:59.9999"
(4)
times = {"00:00:50.0000","00:01:00.0000","00:01:30.0000"}
returns: "00:00:10.0000"
(5)
times = {"59:39:08.3647","59:39:08.3648"}
returns: "00:00:00.0001"Definition
- Class:
- RelayRace
- Method:
- fastest
- Parameters:
- String[]
- Returns:
- String
- Method signature:
- String fastest(String[] param0)
- (be sure your method is public)
Constraints
Examples
No public sample cases were explicitly marked for this problem in the original data.