Code Room
CodingEasycod-g1403
Subject Two pointersLevel Entry–Mid~11 minCommon in Algorithms & data structures interviewsIndustries Software development

Question

A meal-planning app lists menu items by calories in ascending order. Given the sorted list calories and a daily budget, find two different items whose calories add up exactly to the budget. Return their 0-based indices as [i, j] with i < j, or an empty list if no such pair exists. Aim for a single pass with two pointers rather than checking every pair. Example: calories = [150, 250, 300, 450, 600], budget = 550 gives [1, 2].

Implement
find_calorie_pair(calories: list[int], budget: int) → list[int]
Examples
in[[150,250,300,450,600],550]out[1,2]
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.