Plan Round Trip With Minimum Flight Cost
Plan a round trip between 2 cities with minimum flight cost, given departure and return cost arrays.
Asked at:
Meta
Question Timeline
See when this question was last asked and where, including any notes left by other candidates.
Mid April, 2026
Meta
Senior
Plan a round trip between two cities with minimum flight cost. Example: SFO -> Vegas -> SFO Inputs: Date: 0 1 2 3 4 From SFO -> Vegas, Airfare D[] = [10, 8, 9, 11, 7] From Vegas -> SFO, Airfare R[] = [8, 8, 10, 7, 9] Output: Fare = 8 + 7 = 15 Departure Day = 1, Return Day = 3,
Early March, 2026
Meta
Mid-level
Find the minimum cost of a round trip given two arrays ( departure and return) of equal size, where index represents time and value represents flight price. The key constraint is that the return flight must occur after the departure flight. Example: D = [10,8,9,11,7], R = [8,8,10,7,9] Answer: D[1] + R[3] = 15
Early March, 2026
Meta
Staff
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). For eg departing = [1,2,3,4] and returning = [4,3,2,1], the minimum cost for round trip will be 2 i.e departing[0] + returning[3]. Solve this is O(n) time
Hello Interview Premium
Your account is free and you can post anonymously if you choose.