Problem Statement
You will be given a list of tasks that need to be completed today. Each element of tasks will have the form (quotes for clarity) "HH:MM TASK" where HH is between 0 and 23 inclusive, MM is between 0 and 59 inclusive, and TASK is composed of letters ('A'-'Z', 'a'-'z'). Both HH and MM are 2-digit numbers. You will return a String formatted as follows (quotes for clarity): "FirstTask-LastTask". Here FirstTask is the earliest TASK in tasks and LastTask is the latest.
Definition
- Class:
- DayPlanner
- Method:
- getEnds
- Parameters:
- String[]
- Returns:
- String
- Method signature:
- String getEnds(String[] tasks)
- (be sure your method is public)
Constraints
- tasks will contain between 2 and 50 elements inclusive.
- Each element of tasks will contain between 7 and 50 characters inclusive.
- Each element of tasks will be formatted in the way described in the problem statement.
- No two elements of tasks will have the same time.
Examples
{"00:00 FirstTask","10:00 SecondTask"}Returns: "FirstTask-SecondTask"
FirstTask occurs as early as possible. SecondTask occurs 10 hours later.{"00:00 Which","00:01 Is","00:02 Which"}Returns: "Which-Which"
{"00:02 Which","00:01 Is","00:00 Which"}Returns: "Which-Which"
{"00:10 A","01:09 B","02:08 C"}Returns: "A-C"
{"12:00 B","23:59 C","00:00 A"}Returns: "A-C"