Class Name: FlightConnections
Method Name: getMinimum
Parameters: String, String, String
Implement a class FlightConnections, which contains a method getMinimum.
getMinimum takes a String representing a list of available flights, a String
representing the departure city, and a String representing the intended
destination. It returns the minimum number of flights needed to arrive from
the departure city to the destination city.
*If the departure city and the intended destination are the same, no flights
are needed, so return 0.
*If there is no possible connection from the departure city to the destination
city, return 0.
*If either the departure or arrival city is not mentioned in the String,
*City names are case sensitive.
*Departure and arrival times don't play any roll.
*Flights are directional. That is if there is a flight from city A to city B
there isn't necessarily a flight in the reverse direction.
*Duplications in the String are ignored.
String elements are of the form:
"FROM, TO" (There is a comma followed by exactly one space between FROM and TO).
representing a flight from FROM to TO. FROM and TO contain letters and dashes
Here is the method signature:
int getMinimum(String flights, String strDeparture, String strDestination);
Be sure your method is public.
* flights will be a String of the form above. It has between 1 and 20
elements. Each element is at most 50 characters long.
* strDeparture and strDestination will be Strings consisting only of characters
from the set A-Z, a-z, and "-" (dash).
* TopCoder will check the validity of the inputs.
Examples(quotes are for clarity, but not included in the Strings):
Flights: ["T, B", "O, F", "D, Y", "F, K", "K, C", "V, N", "B, O"]
Departure From: T
Minimum flights: 5 (T to B; B to O; O to F; F to K; K to C)
Flights: ["Y, C", "O, F", "Y, O", "M, O", "C, K", "O, K", "K, S", "K, M"]
Departure From: Y
Minimum flights: 0 (the intended destination is the same as the departure
Flights: ["Here, Ba", "Ba, Ya", "Fa, Qa"]
Departure From: Here
Minimum flights: 0 (no possible way to get from Here to Qa)