Shortest Order Window Covering Every Cuisine Type
Last updated: November 29, 2026
Quick Overview
Given a sequence of orders labeled by cuisine, find the shortest contiguous window that contains at least one order of every distinct cuisine in the sequence, returning its start and end indices.
DoorDash
November 29, 20260
0
0 solved
Given a sequence of orders labeled by cuisine, find the shortest contiguous window that contains at least one order of every distinct cuisine in the sequence, returning its start and end indices.
A sliding window problem dressed in DoorDash marketplace data, for example finding the tightest stretch of the dinner rush where a market saw demand for every cuisine it carries. The interviewer looks for the expand and shrink pattern, a correct coverage counter, and clear tie handling.
What the Interviewer Expects
- Count distinct cuisines up front to know the target
- Expand the right edge and shrink the left while covered
- Track coverage with a counter of distinct cuisines currently present
- Update the best window inside the shrink loop
- Prove each index enters and leaves at most once
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
- What if you only need to cover a given subset of cuisines?
- How would you find the shortest window by time span rather than order count?
- What if orders stream in and you need the answer continuously?
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 cuisine strings in time order.
- Find
(start, end), inclusive, of the shortest window containing every distinct cuisine. - Ties: earliest window wins. Empty input returns
None....
High-Level Design
Let need be the number of distinct cuisines. Move right across the array, adding each cuisine to a counter and incrementing covered when a count goes from 0 to 1. While covered == need, the wi...