InterviewDB Experience

Menu Filters: Return Dishes Matching Multiple Dietary Constraints

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

  1. How would you extend this to support OR filters (dish must match at least one of a tag group)?
  2. How would you build an index to make repeated queries O(1) after preprocessing?
  3. If the dish list has 100,000 items and queries come in real time, what data structure supports efficient multi-tag intersection?
  4. 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

  1. How would you extend this to support OR filters (dish must match at least one of a tag group)?
  2. How would you build an index to make repeated queries O(1) after preprocessing?
  3. If the dish list has 100,000 items and queries come in real time, what data structure supports efficient multi-tag intersection?
  4. Extend to support exclusion filters: "must NOT contain nuts" alongside inclusion filters.

About This Question

This is a candidate experience report from a squarespace interview during the onsite round.

It covers the following topics: Coding, Onsite .