Choose the Fewest Cards Whose Bonus Categories Cover Your Spending

Last updated: November 29, 2026

Quick Overview

Given the spend categories a customer cares about and a set of cards with their bonus categories, return the smallest set of cards whose combined bonus categories cover every needed category, or None if no set covers them.

Capital One
Coding & Algorithms
Software Engineer
Capital One
November 29, 2026
Software Engineer
Onsite
Coding & Algorithms
Hard

0

0

0 solved


Given the spend categories a customer cares about and a set of cards with their bonus categories, return the smallest set of cards whose combined bonus categories cover every needed category, or None if no set covers them.

Capital One's card lineup (Savor for dining and entertainment, Venture for travel, Spark for business categories) invites a recommendation question about covering a customer's categories with as few cards as possible. This onsite question is set cover on a small universe, so the interviewer is looking for bitmask encoding and DP over coverage states rather than trying every subset blindly.

What the Interviewer Expects
  • Encode each card's relevant categories as a bitmask
  • Ignore categories the customer does not need
  • Run DP over coverage masks storing the best card set for each mask
  • Return a deterministic answer on ties
  • State the exponential dependence on the number of categories
Key Topics to Cover
Bit manipulation
Bitmask DP
Set cover
Combinatorial optimization
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
  • Set cover is NP-hard. What greedy approximation would you use if there were 200 categories?
  • How would you weight cards by annual fee and minimize total fee instead of card count?
  • How would you include each card's reward rate per category in the objective?
  • How does the complexity compare between DP over masks and brute force over card subsets?
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
  • Needed categories: up to about 16, so masks fit in 2^16 states.
  • Cards: name to bonus categories; categories outside the needed list are irrelevant.
  • Output: the smallest list of card names (sorte...
High-Level Design

Assign bit i to needed category i, and convert each card to a mask, dropping cards that cover nothing useful. Keep best[mask], the best card set that reaches exactly that coverage. Process cards one...


Submit Your Answer
Markdown supported