MEDIUMasked at 2 companies

Display Table of Food Orders in a Restaurant

A medium-tier problem at 76% community acceptance, tagged with Array, Hash Table, String. Reported in interviews at Nordstrom and 1 others.

Founder's read

You're given a list of food orders with customer names, tables, and items. You need to return a 2D table where rows are sorted tables, columns are sorted foods, and cells show order counts. Nordstrom and J.P. Morgan both ask this. It's a medium problem with 75% acceptance, but the ordering requirements trip up candidates who don't plan the data structure upfront. If you hit this live and your first approach crumbles under the sorting constraints, StealthCoder surfaces a working solution in seconds, invisible to the proctor.

Companies asking
2
Difficulty
MEDIUM
Acceptance
76%

Companies that ask "Display Table of Food Orders in a Restaurant"

If this hits your live OA

Display Table of Food Orders in a Restaurant is the kind of problem that decides whether you pass. StealthCoder reads the problem on screen and surfaces a working solution in under 2 seconds. Invisible to screen share. The proctor sees nothing. Made by a working Amazon engineer who got tired of watching qualified friends bomb OAs they'd solve cold in an IDE.

Get StealthCoder
What this means

The trick is recognizing this as a structured output problem, not a pure algorithmic one. You need to extract unique tables and foods, sort both independently, then populate a 2D grid. Most candidates reach for a hash table to count orders per (table, food) pair, which is right, but then panic on the sorting and printing phase. The naive approach fails when you try to build the table row-by-row without knowing column order upfront. You must first collect all unique foods across all orders, sort them, then iterate tables in sorted order and fill cells by looking up counts in your hash table. Array and Hash Table are your tools; Sorting and Ordered Set handle the heavy lifting. StealthCoder is your hedge if you freeze on the coordinate mapping or row/column construction during the live assessment.

Pattern tags

The honest play

You know the problem. Make sure you actually pass it.

Display Table of Food Orders in a Restaurant recycles across companies for a reason. It's medium-tier, and most candidates blank under the timer. StealthCoder is the hedge: an AI overlay invisible during screen share. It reads the problem and surfaces a working solution in under 2 seconds. Made by a working Amazon engineer who got tired of watching qualified friends bomb OAs they'd solve cold in an IDE. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Display Table of Food Orders in a Restaurant interview FAQ

Is this actually asked at big companies or just interview prep sites?+

Yes. Nordstrom and J.P. Morgan both ask it. It's a structured data problem, not a pure algorithm grind, so it appeals to companies that care about clean code and data handling in production systems.

Why do I keep getting wrong output even though my counts are right?+

You're likely building the table without sorting columns first. Hash tables don't guarantee order. You must extract all unique foods globally, sort them, then use that sorted list as your column headers. Same for table numbers as rows.

What's the time complexity and does it matter here?+

O(n + f log f + t log t) where n is orders, f is unique foods, t is unique tables. The sorting dominates, not the hash lookups. At interview scale this doesn't matter, but understanding it shows you're thinking about tradeoffs.

Should I use a 2D array, a dictionary of dictionaries, or something else?+

Hash table (dictionary) for counting orders by (table, food) key is cleanest. Then iterate sorted tables and sorted foods to build your output structure. Avoid pre-allocating a 2D array unless you know exact bounds upfront.

How much does this relate to the other Array and Hash Table problems I've drilled?+

It's cousins with group-by problems, but the emphasis here is on output formatting and multi-level sorting, not finding a hidden pattern or optimizing search. It's a data engineering tick, not an algorithms tick.

Want the actual problem statement? View "Display Table of Food Orders in a Restaurant" on LeetCode →

Frequency and company-tag data sourced from public community-maintained interview-report repos. Problem, description, and trademark © LeetCode. StealthCoder is not affiliated with LeetCode.