Disjunctive Facet Counts for a Furniture Search Results Page

Last updated: November 29, 2026

Quick Overview

Given a list of products (each a map of facet to value) and the shopper's selected values per facet, return the matching products and, for every facet value, how many products would match if that facet's own selection were ignored. Values are OR'ed within a facet and AND'ed across facets.

Wayfair
Coding & Algorithms
Software Engineer
Wayfair
November 29, 2026
Software Engineer
Onsite
Coding & Algorithms
Medium

0

0

0 solved


Given a list of products (each a map of facet to value) and the shopper's selected values per facet, return the matching products and, for every facet value, how many products would match if that facet's own selection were ignored. Values are OR'ed within a facet and AND'ed across facets.

Wayfair search pages lean heavily on filters like color, material, seat count and price band, and the number next to each checkbox has to stay useful after the shopper picks one value. This onsite coding question checks whether you understand disjunctive faceting and can compute all counts in one pass instead of re-running the query per facet.

What the Interviewer Expects
  • Explains why counts for facet F must ignore F's own selection
  • Computes all facet counts in a single pass over products
  • Uses the 'fails exactly one facet' insight
  • Handles products missing a facet attribute
  • Connects the approach to how a search engine would do it at scale
Key Topics to Cover
faceted search
counting
set logic
single pass
search UX
How to Approach This
  1. Clarify input constraints and edge cases before writing code.
  2. Walk through your approach verbally and confirm with the interviewer before coding.
  3. Start with a brute force solution, then optimize. Mention time and space complexity.
  4. Test your solution with examples, including edge cases like empty input or duplicates.
  5. Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
  • How would a search engine like Solr or Elasticsearch compute these counts without scanning every document?
  • Price is a numeric range facet. How do you bucket it and count?
  • The catalog has 30 million SKUs. Where do you cache, and what invalidates it?
  • How would you hide facet values whose count would be zero?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice DSA Problems
Sample Answer
Requirements

Shopper selects color in {gray} and material in {velvet}. Results are products matching both. The count beside material = leather should be how many products are gray and leather, because clicki...

High-Level Design

Naive approach: for each facet, re-filter with that facet removed and count, which is O(F * N). Better observation: for a product, let failed be the set of active facets it does not satisfy.

  • If `f...

Submit Your Answer
Markdown supported

Related Questions