Get Minimum Round Trip Cost
There are 2 arrays which denote departing and returning flights with the respective indexes being time and the values of the array being the cost it takes for the flight. Return the minimum cost for a round trip provided the return flight can only be taken at a time post departing flight time (i.e if departing at time i, one can catch a returning flight only from time (i+1) onwards).
Complete the function getMinimumRoundTripCost in the editor.
getMinimumRoundTripCost has the following parameters:
- 1.
int[] departing: an array of integers representing the cost of departing flights - 2.
int[] returning: an array of integers representing the cost of returning flights
Returns
int: the minimum cost for a round trip
1Example 1
The minimum cost for a round trip can be obtained by taking the departing flight at time 0 with cost departing[0] = 1 and the returning flight at time 3 with cost returning[3] = 1. The total minimum cost is 1 + 1 = 2.