Code RoomClosest snack drink combo
MediumPrep Room Coding #618

Closest snack drink combo

CodingAlgorithms & data structuresEntry–Mid~15 min

A vending kiosk shows snack calories and drink calories, each list sorted ascending and non-empty. A customer picks exactly one snack and one drink, aiming for combined calories as close as possible to a target; if two combos are equally close, they take the lower-calorie one. Return that combined calorie count. Use one pointer per list in a single O(n + m) walk. Example: snacks = [100, 250], drinks = [50, 120], target = 300 gives 300 (250 + 50).

Implement
closest_combo_sum(snacks: list[int], drinks: list[int], target: int) → int
Examples
in[[100,250],[50,120],300]out300
What 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.

0:00 of about 15 min
InputExpectedGot
[[100,250],[50,120],300]300not run yetsample