Stripe logo

Stripe

San Francisco, CAFintech

Interview Questions

Money Transfer Optimization

Asked at Stripe
technical
algorithms
optimization

Optimize money redistribution across bank accounts to meet threshold requirements.

Problem: Given array of account balances and threshold, redistribute money to ensure all accounts exceed threshold.

Example: Input:

  • Accounts: [3, 5, 11, 28]
  • Threshold: 10

Steps:

  1. Transfer 7 from index 3 to 1: [3, 12, 11, 21]
  2. Transfer 5 from index 3 to 2: [3, 12, 16, 16]

Final: [10, 10, 11, 16]

Follow-up:

  • Consider transfer costs
  • Minimize number of transfers
  • Handle edge cases

Account Balance Manager: StripePay Backend

Asked at Stripe
technical
system design
backend
transactions

Design a backend system for StripePay that handles user transactions and balance management.

Requirements:

  • Handle transactions in chronological order
  • Support bank transfers and peer-to-peer payments
  • Process commands with timestamps
  • Maintain accurate account balances

Supported Commands:

  1. INIT Command
Usage: INIT,name,balance,bank_1,bank_2,...,bank_n
Purpose: Initialize user account with starting balance and connected banks
Example: INIT,Alice,100,BankA,BankB
Response: No response value
  1. POST Command
Usage: POST,timestamp,sender,receiver,amount
Purpose: Process money transfers between users or banks
Example: POST,169800812,Bob,Alice,50

Rules:
- Prevent negative balances
- Handle bank deposits/withdrawals
- Validate bank connections
- Verify user accounts exist

Response: SUCCESS or FAILURE
  1. GET Command
Usage: GET,timestamp,name
Purpose: Retrieve account balance at specific timestamp
Example: GET,2,Alice
Response: Balance amount or FAILURE

Constraints:

  • Maximum 1 command per second
  • Banks cannot share names with users
  • Commands must be executed in chronological order
  • All timestamps and commands will be properly formatted

Output Format: Return comma-separated string of command responses in sequential order of input commands.

Share Your Experience at Stripe