Reconcile A Claimed Total Against Itemized Bill Lines

Last updated: November 29, 2026

Quick Overview

A provider's ledger states a total balance, but the itemized lines extracted from the same packet do not obviously add up to it. Find the smallest set of line items whose amounts sum exactly to the stated total, or report that none exists.

EvenUp
Coding & Algorithms
Software Engineer
EvenUp
November 29, 2026
Software Engineer
Onsite
Coding & Algorithms
Hard

0

0

0 solved


A provider's ledger states a total balance, but the itemized lines extracted from the same packet do not obviously add up to it. Find the smallest set of line items whose amounts sum exactly to the stated total, or report that none exists.

Before a demand cites a provider balance, EvenUp's pipeline needs to know which itemized charges that balance actually covers, since ledgers mix prior balances, partial statements and duplicates. The interviewer wants to see you recognize subset sum, pick a pseudo-polynomial DP in integer cents, and avoid the classic reconstruction bug.

What the Interviewer Expects
  • Identifies the problem as 0/1 subset sum with a minimum-cardinality objective
  • Works in integer cents so exact equality is meaningful
  • Uses a DP over reachable sums and processes each item once
  • Reconstructs the chosen indices correctly without reusing an item
  • Discusses when the state space is too large and what to do instead
Key Topics to Cover
Dynamic programming
Subset sum
Reconstruction
Pseudo-polynomial time
Money handling
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
  • What if the target can be off by a small rounding tolerance?
  • The total in cents is 4,000,000 with 300 lines: what is the cost, and how do you prune?
  • How would you return all minimal solutions so a reviewer can choose?
  • How would you use dates of service to restrict candidates first?
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

Input: amounts_cents (non-negative integers) and target_cents. Return sorted indices of a subset summing exactly to the target using the fewest items, or None. Each line may be used at most once...

High-Level Design

Subset sum is NP-hard in general, but amounts are integers bounded by the target, so a DP over reachable sums is O(n * T). Keep a dictionary from reachable sum to the fewest-item index tuple that reac...


Submit Your Answer
Markdown supported

Related Questions