Split a Marketplace Payment Across Linked Accounts Without Losing Paise
Last updated: November 29, 2026
Quick Overview
A marketplace on Razorpay Route splits each customer payment among linked accounts (seller, platform, delivery partner) by integer weights. Return an integer paise amount for each account such that the parts sum exactly to the payment and each part is within one paisa of its exact share.
Razorpay
November 29, 20260
0
0 solved
A marketplace on Razorpay Route splits each customer payment among linked accounts (seller, platform, delivery partner) by integer weights. Return an integer paise amount for each account such that the parts sum exactly to the payment and each part is within one paisa of its exact share.
Route lets marketplaces transfer parts of a payment to multiple linked accounts, and naive rounding either loses a paisa or over-transfers. This onsite coding question checks that you can guarantee conservation of money, keep results deterministic, and reason about fairness of rounding.
What the Interviewer Expects
- Use integer division with remainders, not floats
- Distribute leftover paise by largest remainder
- Break ties deterministically
- Prove the parts sum to the original amount
- Validate weights
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
- The platform wants any rounding paise to always go to itself. How does the code change?
- How would you split with fixed-amount transfers plus a percentage remainder?
- How do you reverse a split proportionally when the customer gets a partial refund?
- Why must this be deterministic across retries?
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: amount in paise and a list of (account_id, weight) with positive integer weights. Output: {account: paise} where the sum equals the amount exactly, and each value is either the floor or the...
High-Level Design
Compute each floor share and remainder with divmod(amount * w, W). The floors sum to at most amount - 1 short per account, and the deficit leftover = amount - sum(floors) is always less than the...