Code Room
CodingMediumcod-g1421
Subject Two pointersLevel Entry–Mid~15 minCommon in Algorithms & data structures interviewsIndustries Software development

Question

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.

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.