Build Every Combo Meal That Fits a Calorie Budget
Last updated: November 29, 2026
Quick Overview
Given menu items as (name, calories, category), list every combo that picks at most one item per category, includes at least a minimum number of items, and stays within a calorie budget.
DoorDash
November 29, 20260
0
0 solved
Given menu items as (name, calories, category), list every combo that picks at most one item per category, includes at least a minimum number of items, and stays within a calorie budget.
A backtracking question built around a healthy-choices filter on a restaurant's menu page. DoorDash interviewers use it to check that you structure the search by category, prune early with sorted items, and know when enumeration is acceptable versus when you would need DP or a cap on output size.
What the Interviewer Expects
- Group items by category and choose or skip each category
- Sort items by calories so the loop can break early
- Prune branches that cannot reach the minimum item count
- Produce deterministic, deduplicated output
- Discuss output-sensitive complexity
Key Topics to Cover
How to Approach This
- Clarify input constraints and edge cases before writing code.
- Walk through your approach verbally and confirm with the interviewer before coding.
- Start with a brute force solution, then optimize. Mention time and space complexity.
- Test your solution with examples, including edge cases like empty input or duplicates.
- Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
- How would you return only the k combos with the most protein?
- What if a category allows up to two items?
- How would you count combos without listing them when the menu is large?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice DSA ProblemsSample Answer
Requirements
- Input: list of
(name, calories, category),budget,min_items(default 2). - At most one item per category; total calories
<= budget; at leastmin_itemsitems. - Output: sorted list of comb...
High-Level Design
Group items by category and sort each group by calories. Recurse over categories in a fixed order. At each category, first try skipping it, then try each item that fits the remaining budget; because i...