Closest snack drink combo
Your task
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).
Examples
closest_combo_sum(snacks: list[int], drinks: list[int], target: int) -> intExample 1
Input
closest_combo_sum([100, 250], [50, 120], 300)Output
300