Two-item calorie pair

Write codeEasy11 min

Your task

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].

Examples

find_calorie_pair(calories: list[int], budget: int) -> list[int]
Example 1
Inputfind_calorie_pair([150, 250, 300, 450, 600], 550)
Output[1, 2]