← 返回 meta 的题目列表Minimum Round Trip Cost
类型:online_judge
meta
Given two integer arrays, FROM and TO, both of the same length, where FROM[i] and TO[i] represent the cost of a one-way ticket from city A to city B and from city B to city A on the i-th day, respectively. Find the minimum cost of a round trip from city A to city B and back to city A.
Implement a function find_min_trip_cost(FROM: List[int], TO: List[int]) -> int.
Select two different indices i and j in FROM and TO, respectively, such that FROM[i] + TO[j] is minimized.
Example:
FROM = [1, 3, 2, 5], TO = [5, 3, 2, 1] returns 2 because the cheapest round trip ticket is 1 + 1.
Assumptions:
All ticket prices are positive integers.
Please return the minimum round-trip ticket cost.
Take note of efficiency and edge cases.
Example
Input
[1, 3, 2, 5]
[5, 3, 2, 1]