Problem Statement
A new air line company is being formed by purchasing a set of smaller companies. Each of the small companies owns a single plane, and makes round trip flights between two cities.
The new airline must provide some way for a traveller to go between any two cities, but it might not be a direct flight.
Create a class Airline with a method cost that takes a String[] flights that represents the flights that are handled by smaller companies we might purchase, and returns a int that represents the minimum expenditure required to start the new air line company.
Definition
- Class:
- Airline
- Method:
- schedule
- Parameters:
- String[]
- Returns:
- int
- Method signature:
- int schedule(String[] messages)
- (be sure your method is public)
Constraints
- flights will contain between 0 and 50 elements inclusive.
- Each element of flights will contain the airport codes of two cities serviced by a company separated by a single space (' '), followed by the cost of purchasing this company.
- Each airport code will consist of exactly three uppercase letters ('A'-'Z').
- The cost of purchasing a company will be between 1 and 10000 inclusive.
Examples
No public sample cases were explicitly marked for this problem in the original data.