InterviewLegend

Menu Trees: Find, Price & Parse

Alex Chen45 min readGuide updated
In this lesson
  • Price a menu tree where an unpriced node sums its children
  • Find an item in nested groups with BFS and return its path
  • Inherit a missing price from the nearest priced group or menu
  • Parse an indented text menu into a tree with a stack
  • Weight item prices by depth, then flip the weights

Toast builds software for restaurants, and its coding rounds borrow the domain. Toast's own technical interview page says you'll work through "a series of technical exercises with different Toasters based on problems in our restaurant domain", and graph traversal sits first on its list of topics to brush up. A menu is the most natural tree in a restaurant. A lunch menu holds groups, groups hold more groups, and somewhere at the bottom sit the items people order.

That tree has come up in more Toast reports than any other coding problem, from a December 2022 Android loop to a November 2026 question-bank entry. This lesson works five versions of it, current ones first. You'll price a menu where unpriced groups add up their children, then find an item hiding several groups deep. The older section covers a price inherited from above, a menu parser and a depth-weighted sum.

The Toast angle
Leave code that runs, with tests you can show. Toast's page says you'll describe edge cases, testing and scalability as you code. A September 2026 candidate reached the final coding round, where running tests was the minimum bar, and failed partly because their code had no harness to run them. Build a small test menu first.

How Toast asks menu tree questions

The rounds tend to hand you classes that already exist. A Principal candidate in July 2025 posted the Java starter from their getPrice round, and it's a good picture of what you walk into. There are three node types, every price is a nullable Double, and a static block builds a Lunch menu and a Drinks menu for you to test against. Stripped down, it looks something like this:

java
static class Menu {
String name;
List<MenuGroup> groups;
Double price; // nullable
}
static class MenuGroup {
String name;
List<MenuGroup> groups;
List<MenuItem> items;
Double price; // nullable
}
static class MenuItem {
String name;
Double price; // nullable
}
static Double getPrice(Collection<Menu> menus, MenuItem item) { ... }

So the round is half reading. A September 2024 phone-screen candidate found the problem itself easy and the classes hard, with a hierarchy that went too deep. They made a few edge-case slips and didn't move forward. Spend the first minutes on the classes. Ask which fields can be null, whether names repeat, and whether a menu can hold items directly.

All five are one walk over the same tree, and they differ in which way the information moves. A price that sums its children travels up from the leaves. An inherited price travels down from the menu. A search carries the path down and stops at the first match, and a depth weight is a counter that each child gets one higher than its parent.

Current problems (2026)

Two menu problems have 2026 dates. The pricing problem is the newest, though it comes from a question bank and not from a candidate's own account, so it's secondhand. The search problem has the most reports behind it: an April 2026 Senior loop, an early 2025 technical interview and a 2022 Android round.

Price a menu where unpriced nodes sum their children (November 2026). A question bank's Toast list added something like this in November 2026, marked easy and tagged software engineer. Menus, groups and items are nodes, and a node without its own price is worth the sum of its children. The entry builds the tree through a handful of add methods, the shape below.

1

Hierarchical Menu Pricing

EasyCommonly asked
Problem
Build a MenuSystem that stores a restaurant menu as a tree. Calling addMenu(id) creates a menu, the root of a tree, which never has a price of its own. The calls addGroup(id, price) and addItem(id, price) create a group or an item, where price is a whole number of cents or null when it isn't set. Then addChild(parentId, childId) attaches an existing node under an existing parent.

The method getPrice(id) returns a node's own price when it has one. When it doesn't, it returns the sum of getPrice over its children. An unpriced node with no children is worth 0.

A price of 0 is a real price. A group priced at 0 returns 0 even when its children cost something.
  1. MenuSystem()
  2. addGroup("combo", 2000)
  3. addItem("burger", 800)
  4. addItem("fries", 400)
  5. addChild("combo", "burger")
  6. addChild("combo", "fries")
  7. getPrice("combo")→ 2000
  8. getPrice("fries")→ 400

The combo has its own price, so its children never get added up. Fries on its own is still 400.

How this uses the pattern

Keep two maps keyed by id, one for the own price and one for the list of children. getPrice returns the own price when it is not null and otherwise recurses into the children and adds them up.

Write it here, or go full screen with the problem, hints and solution beside the editor.

Hierarchical Menu Pricing

Loading...
Click "Run" to execute your code
The Toast angle
The entry is marked easy, and the code is a few lines. The grading sits in the edges. Keep "not set" apart from zero, since a free group priced at 0 must stop the sum. Decide what an unpriced leaf is worth and say it out loud. Store prices as integer cents, because summing Double prices drifts by fractions of a cent. Toast's page asks you to talk through testing, so build the two-level dinner menu as your first test before you write getPrice.
Take it further
Cache the reads, then let prices change. The same entry lists caching for a menu that is read far more than it is edited, a setPrice that changes or clears a price, and one item sitting in several groups. These are practice extensions from the bank, so treat them as likely directions and not as a script. The catch is invalidation. When a price changes, every cached ancestor is stale, so each node needs a list of its parents to walk up.

Find an item in a nested menu (April 2026). A Senior candidate in Bengaluru listed "Menu traversal (DFS)" among their April 2026 questions, next to a restaurant system design and a code review. An early 2025 technical interview gave a menu with groups inside groups, something like Salads holding Vegetarian Salads holding Vegan Salads, and asked for the logic to fetch a requested item. A December 2022 Senior Android candidate was told the topic ahead of time and got a breadth-first search over a restaurant menu.

None of the three reports says what comes back or what happens when two items share a name. The version below returns the path to the item and, on a tie, the copy nearest the top. That tie is the one place where BFS and DFS give different answers.

2

Find an Item in a Nested Menu

MediumSignature problem
Problem
You get a list of menus and the name of an item. A menu is an object with a name and a list of groups. A group has a name, a list of items and a list of nested groups, and an item has a name.

Return the path to the item as a list of names, starting with the menu and ending with the item. Return an empty list when no item has that name. Groups never match, only items.

When more than one item has the name, return the one with the fewest groups above it. Among equally deep copies, the one that comes first in menu order wins.
Inputmenus = [{"name":"Lunch","groups":[{"name":"Salads","items":[{"name":"Caesar Salad"}],"groups":[{"name":"Vegan Salads","items":[{"name":"Kale Bowl"}],"groups":[]}]}]}]name = "Kale Bowl"Output["Lunch","Salads","Vegan Salads","Kale Bowl"]

Kale Bowl sits two groups down. The path lists every name on the way.

How this uses the pattern

Breadth-first search with a queue of (node, path) pairs. When you take a node off the queue, check its items for the name before you queue its subgroups.

Write it here, or go full screen with the problem, hints and solution beside the editor.

Find an Item in a Nested Menu

Loading...
Click "Run" to execute your code
The Toast angle
The April 2026 report says DFS and the 2022 one says BFS, and both find the item. They part ways on a tie. DFS returns the first copy in menu order, however deep, while BFS returns the shallowest. Ask which one the interviewer wants and name the trade before you code. The deep hierarchy also bit a 2024 candidate on edge cases, so check an empty menu list, an empty group and a name that only matches a group.
Take it further
Return every match, or match loosely. A natural next step is returning every path where the name appears, which means the same walk without the early return. Another is matching "kale bowl" to "Kale Bowl", which means normalising case and spaces once when you compare. If the menu is searched constantly, build a map from item name to path once and answer each search with one lookup. Say how you'd rebuild that map when the menu changes.

Older problems (2024-2025)

Three more versions come from 2024 and 2025, and each rests on a single report. They're worth the time because they reuse the same tree with a different twist. One price flows down instead of up, the parser has to build the tree from text, and the depth sum counts levels on the way down.

Inherit a missing price from the nearest group (July 2025). The third round of a Principal loop was to write getPrice on the classes shown earlier. An item with a null price takes the price of the closest enclosing group that has one, and failing that, the menu's. The posted Lunch and Drinks menus are the data below, converted to cents, with one item name shortened.

Lunch 1150
├── Appetizers 500 Wings (null), Fries 350
└── Entrees (null) Burger (null)
├── Salads 750 Garden Salad (null), Cobb Salad 900
└── Toast 650 Avocado (null), PB&J (null)
Drinks 500
├── Coffees (null)
│ ├── Iced 500 Iced Latte 650, Decaf Iced Coffee (null)
│ └── Hot 300 Americano (null), Cup of Joe (null)
└── Sodas 250 Coke, Sprite, Ginger Ale (all null)
3

Menu getPrice With Inherited Prices

MediumSometimes asked
Problem
You get a list of menus and the name of an item. A menu has a name, a price and a list of groups. A group has a name, a price, a list of items and a list of nested groups. An item has a name and a price. Every price is a whole number of cents or null.

Return the item's price. When the item's own price is null, use the price of the nearest enclosing group that has one, and if no group above it has a price, use the menu's.

Return null when no item has that name, or when nothing on its path has a price. If the name appears more than once, use the first copy in menu order, where a group's items come before its subgroups.
Inputmenus = [Lunch, Drinks] as postedname = "Wings"Output500

Wings has no price. Its group, Appetizers, is priced at 500.

How this uses the pattern

Walk down from each menu and carry the nearest price you have seen so far. A group with its own price replaces it. When you reach the item, its own price wins if it has one, otherwise return the price you carried.

Write it here, or go full screen with the problem, hints and solution beside the editor.

Menu getPrice With Inherited Prices

Loading...
Click "Run" to execute your code
The Toast angle
The posted signature takes the item as a MenuItem and returns a Double, so a null price and a missing item both come back as null. Say which one you mean. The posted attempt also compared names with ==, which in Java compares object identity. It can pass on literals and still fail on a name read from input. The candidate's Principal loop also had two peer-coding rounds on existing code, so expect to extend the classes you're given before writing your own.
Take it further
Price every item in one pass. If the menu is priced once and read many times, walk it once, carry the inherited price down, and fill a map from item name to final price. Every later lookup is then O(1). The worked version is below. A second direction is a node that sits in two groups with different prices, where you'd have to ask which parent wins.

Parse and store a restaurant menu (November 2025). A Senior candidate in Bengaluru, who got an offer, described a "design round" where they had to write code that parses and stores restaurant menus. They rated it medium, and a high-level design round on their own past projects came after it. The report gives no input format, so the indented text below is one plausible shape. Ask what format you'll get before you write a parser.

4

Restaurant Menu Parser

MediumSometimes asked
Problem
Build a MenuStore. load(text) reads a menu written one entry per line, where each level of nesting is indented by two more spaces than its parent and a line at no indent starts a new menu. An entry may end with a price like $3.50 or $12, which you store in cents. Blank lines are skipped.

The method returns a list of errors, one string per bad line. An indent that isn't a multiple of two gives "odd indent on line N". A line indented more than one level past the line before it, or a first line that is indented at all, gives "indent jumps a level on line N". A price that isn't digits with an optional two-digit decimal part gives "bad price on line N". Line numbers count from 1 and include blank lines.

If load finds any error it stores nothing and returns the errors. Otherwise it adds the menus to the store and returns an empty list. The method children(name) returns the names directly under an entry, in order, or an empty list. The method price(name) returns an entry's own price in cents, or null when it has none or doesn't exist.
  1. MenuStore()
  2. load("Lunch\n Appetizers $5.00\n Wings\n Fries $3.50\n Entrees\n Burger $12")→ []
  3. children("Lunch")→ ["Appetizers","Entrees"]
  4. children("Appetizers")→ ["Wings","Fries"]
  5. price("Fries")→ 350
  6. price("Wings")
  7. price("Burger")→ 1200

Two spaces per level. Entrees goes back up one level, so it sits under Lunch next to Appetizers.

How this uses the pattern

Validate every line first and collect the errors. If there are none, build the tree with a stack holding the current path. A line at level k pops the stack down to k entries, becomes a child of the new top, then is pushed itself.

Write it here, or go full screen with the problem, hints and solution beside the editor.

Restaurant Menu Parser

Loading...
Click "Run" to execute your code
The Toast angle
The report calls it a design round, so the parser is only half of it. Talk about where parsing ends and storage begins, what happens to a half-good file, and how you'd test each rule. All-or-nothing loading is one defensible choice, since a menu that silently drops a group can put a wrong price in front of a guest. Toast's topic list includes string manipulation and data modeling, and this round touches both.
Take it further
Change the format or the storage. Real menus may arrive as JSON from an API, where parsing is free but validation still isn't, so ask what a broken group looks like there. Another follow-up is repeated names, two groups both called Specials, which breaks lookup by name. Give each entry an id or store its full path as the key. A third is reloading a menu, which means deciding whether a load replaces a menu of the same name or merges into it.

Depth-weighted menu sum (September 2024). A phone screen asked a variation of LeetCode's nested list weight sum, set in a restaurant menu. The candidate shared little beyond that, apart from the deep class hierarchy and a few missed edge cases. The menu framing below is one reading of it, where each item's price is weighted by how deep it sits.

5

Depth-Weighted Menu Sum

MediumRarely asked
Problem
You get one menu. The menu and every group in it have a name, a list of items and a list of nested groups. Each item has a name and a whole-number price.

An item sitting directly in the menu has depth 1. An item in a group directly under the menu has depth 2, and each further level of nesting adds 1.

Return the sum of every item's price multiplied by its depth. A menu with no items returns 0.
Inputmenu = {"name":"Bar","items":[{"name":"Bread","price":2}],"groups":[{"name":"Snacks","items":[{"name":"Olives","price":1},{"name":"Nuts","price":1}],"groups":[]},{"name":"Dips","items":[{"name":"Salsa","price":1},{"name":"Hummus","price":1}],"groups":[]}]}Output10

Bread is at depth 1 for 2. The four items at depth 2 add 4 times 2. That is the classic [[1,1],2,[1,1]].

How this uses the pattern

Walk the tree with a stack of (node, depth) pairs. Add each item's price times the node's depth, and push each subgroup with depth plus one.

Write it here, or go full screen with the problem, hints and solution beside the editor.

Depth-Weighted Menu Sum

Loading...
Click "Run" to execute your code
The Toast angle
A 2024 candidate said this problem's hierarchy went too deep. They felt their solution was right apart from minor edge cases, and they didn't move forward. So spend your effort on the edges. Test an empty menu, a group with no items, a chain of empty groups, and an item priced at 0. Write those tests before the walk, and run them out loud as you go.
Take it further
Flip the weights. LeetCode's sequel weights the deepest items by 1 and the top by the maximum depth. You need the maximum depth first, so it becomes two passes, one to measure depth and one to sum. A neat one-pass alternative keeps a running total of each level's sum and adds it again at every deeper level. The two-pass version is worked below.

What gets you through the round

The five problems share one tree, and the reports that went badly share a cause. In the 2024 phone screen, a working idea slipped on edge cases in a deep hierarchy. At the September 2026 final round, running tests was the minimum, and the candidate's code couldn't run any. Neither failure came from the algorithm.

Read the classes, build a test menu, then write the walk. Ask which fields can be null and whether names repeat. Build a small menu with a priced group, an unpriced group and a nested group, and keep a main method or test function that prints each result. Code in Java, JavaScript, Python or Kotlin, which are the languages Toast lists, and use integer cents for money.

Common questions

What coding questions does Toast ask?

Mostly practical problems set in a restaurant. The menu tree on this page is the most repeated, as pricing, search, inherited prices, parsing and a depth sum. Other rounds have asked for labor clock-in endpoints, top restaurants by order value in a partly built system, and a code review of an existing API. What Toast Tests in Coding maps the rounds.

Does Toast ask LeetCode questions?

Sometimes, though most problems carry restaurant dressing. The 2024 phone screen here was a menu version of nested list weight sum, and a stock-profit variant came up in two 2025 coding rounds. Expect a LeetCode shape under restaurant names more often than a problem copied straight from the site.

Which language should I use in a Toast coding interview?

Toast's technical interview page lists JavaScript, Java, Python and Kotlin, and says to ask ahead of time for anything else. The posted menu starter was Java, so if you pick Python, be ready to read Java classes and mirror them. Toast also asks you not to use real-time AI tools during interviews unless told otherwise.

How should I practice these menu problems?

Write each one from a blank file with your own test menu, and time it at about 30 minutes. Then do the follow-ups out loud: a cache with setPrice, every match instead of the first, one pass that prices every item. If you're told the topic ahead of time, as a 2022 Android candidate was, drill that walk twice.

Key Takeaways

  • ✓Toast's most repeated coding problem is a restaurant menu tree, asked as pricing, search, inherited prices or parsing.
  • ✓Summed prices flow up from the leaves and inherited prices flow down, so pick the walk direction first.
  • ✓Keep money in integer cents and test for null explicitly, because a price of 0 is real.
  • ✓Read the given classes, ask about nulls and repeated names, and leave code with tests that run.
Toast interview guide

Know what Toast asks before you walk in.

24 coding · 3 system design · 17 behavioral questions

Get Premium$49 a year · Instant access
Or start freeNo card.

Get their questions first.

What Toast Tests in CodingHad your Toast interview?How we research

InterviewLegend is independent and not affiliated with or endorsed by any company it covers.