Find Stores That Offer Every Requested Service Using Bitmasks
Last updated: November 29, 2026
Quick Overview
Each store lists the services it offers, such as pharmacy, vision center, auto care or pickup. Given a list of requested services, return the ids of stores offering all of them, using bitmasks for the comparison.
Walmart Labs
November 29, 20260
0
0 solved
Each store lists the services it offers, such as pharmacy, vision center, auto care or pickup. Given a list of requested services, return the ids of stores offering all of them, using bitmasks for the comparison.
The Walmart store finder filters thousands of stores by services. This Walmart Labs online assessment warm-up checks whether you can encode sets as integers and use a single AND to test containment.
What the Interviewer Expects
- Map each service name to a bit position
- Build an integer mask per store
- Test containment with mask AND need equals need
- Handle a requested service that no store offers
- State complexity relative to the number of services
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
- How would you find the minimum number of stores that together cover all requested services?
- What if there are more than 64 services in a language with fixed size integers?
- How would you combine this with a distance filter around a zip code?
- How could you precompute answers for the most common service combinations?
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: dict store_id -> list of service names and a list of requested services. Output: sorted store ids whose services include every requested one. No request means every store qualifies. A request...
High-Level Design
Assign each distinct service a bit index as we see it. A store's offering becomes an integer with those bits set. The request becomes need. A store qualifies when mask & need == need, a single mac...