Code Room
CodingMedium
Question
A company is interviewing 2n candidates. Flying candidate i to city A costs costs[i][0] and to city B costs costs[i][1]. Exactly n people must go to each city. Return the minimum total cost to fly everyone such that the cities are evenly split. The input has an even length up to 200; all costs are non-negative integers.
Implement
two_city_cost(costs: list[list[int]]) → intExamples
in
[[[10,20],[30,200],[400,50],[30,20]]]out110What a strong answer looks like
State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.
Learn the concepts
Vibe coding: describe the solution in plain language (or narrate it) and the coach grades your approach. Generating runnable code from your description is coming next.
Run or narrate your approach, then ask the coach.