Split a Platform Fee Across Payouts Without Losing a Cent

Last updated: November 29, 2026

Quick Overview

A platform pays out a batch of USD payouts and owes one total fee in cents; allocate the fee across payouts proportionally to their amounts so the shares are whole cents and sum exactly to the total.

Bridge
Coding & Algorithms
Software Engineer
Bridge
November 29, 2026
Software Engineer
Technical Screen
Coding & Algorithms
Easy

0

0

0 solved


A platform pays out a batch of USD payouts and owes one total fee in cents; allocate the fee across payouts proportionally to their amounts so the shares are whole cents and sum exactly to the total.

Payouts infrastructure at Bridge has to show each recipient a fee line, and finance reconciles the batch total to the cent. The interviewer is checking that you avoid floating point for money and know a deterministic rounding scheme that never leaks or invents a cent.

What the Interviewer Expects
  • Use integer minor units or exact arithmetic, never floats
  • Explain largest-remainder allocation and why the sum is exact
  • Make tie breaking deterministic so reruns produce identical results
  • Handle zero totals and zero-volume batches explicitly
  • Test with a case that actually needs rounding
Key Topics to Cover
money arithmetic
largest remainder method
integer division
determinism
rounding
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 you allocate when amounts are in different currencies?
  • A minimum fee of 1 cent applies to every payout. How does the algorithm change?
  • Why might finance prefer the remainder go to the largest payout rather than the largest fractional part?
  • How would you make this auditable months later?
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

Inputs: total_fee_cents (non-negative int) and a list of payout amounts in cents. Output: a list of integer fee shares, one per payout, with sum(shares) == total_fee_cents, each share as close as ...

High-Level Design

Compute each exact share as a fraction using integer division: divmod(total * amount, gross) gives the floor and a remainder. Floors sum to at most total, and the shortfall leftover is smaller t...


Submit Your Answer
Markdown supported

Related Questions