InterviewDB
Experience
Menu Filters: Return Dishes Matching Multiple Dietary Constraints
Onsite
Interview Experience
Problem
You are given a list of dishes, each with a name and a set of tags (e.g., "vegan", "gluten-free", "nut-free"). Given a set of required tags,
return all dishes that satisfy ALL required tags, sorted alphabetically by dish name.
python
def filter_menu(
dishes: list[dict], # [{"name": str, "tags": list[str]}, ...]
required_tags: list[str]
) -> list[str]:
"""Return sorted list of dish names matching all required tags."""
pass
**Input**:
dishes = [
{"name": "Salad", "tags": ["vegan", "gluten-free"]},
{"name": "Burger", "tags": ["gluten-free"]},
{"name": "Smoothie","tags": ["vegan", "nut-free"]},
]
required_tags = ["vegan", "gluten-free"]
**Output**: ["Salad"]
Follow-ups
- How would you extend this to support OR filters (dish must match at least one of a tag group)?
- How would you build an index to make repeated queries O(1) after preprocessing?
- If the dish list has 100,000 items and queries come in real time, what data structure supports efficient multi-tag intersection?
- Extend to support exclusion filters:
"must NOT contain nuts"alongside inclusion filters.
Full Details
Problem
You are given a list of dishes, each with a name and a set of tags (e.g., "vegan", "gluten-free", "nut-free"). Given a set of required tags,
return all dishes that satisfy ALL required tags, sorted alphabetically by dish name.
python
def filter_menu(
dishes: list[dict], # [{"name": str, "tags": list[str]}, ...]
required_tags: list[str]
) -> list[str]:
"""Return sorted list of dish names matching all required tags."""
pass
**Input**:
dishes = [
{"name": "Salad", "tags": ["vegan", "gluten-free"]},
{"name": "Burger", "tags": ["gluten-free"]},
{"name": "Smoothie","tags": ["vegan", "nut-free"]},
]
required_tags = ["vegan", "gluten-free"]
**Output**: ["Salad"]
Follow-ups
- How would you extend this to support OR filters (dish must match at least one of a tag group)?
- How would you build an index to make repeated queries O(1) after preprocessing?
- If the dish list has 100,000 items and queries come in real time, what data structure supports efficient multi-tag intersection?
- Extend to support exclusion filters:
"must NOT contain nuts"alongside inclusion filters.
Free preview. Unlock all Squarespace questions →
About This Question
This is a candidate experience report from a squarespace interview during the onsite round.
More Squarespace Interview Questions
1p3a
Squarespace Software Engineer Tech Screen Range Intersection Coding Question
LeetCode
#88 Merge Sorted Array
InterviewDB
Numbers That Belong: Find All Integers in a Range Satisfying a Digit Rule
InterviewDB
Slideshow Frontend: Build an Auto-Advancing Image Carousel Component
LeetCode
#1893 Check if All the Integers in a Range Are Covered