FastPrepBrazilian Receivables Part 3 — Partial Contracts
Problems/Brazilian Receivables Part 3 — Partial Contracts

Brazilian Receivables Part 3 — Partial Contracts

Stripe logoStripe● MediumNEW GRADPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in a Stripe new-grad phone screen. The linked report gives the layouts and the first two changes. A candidate follow-up gives the rule and example for partial contracts. The source does not limit the output order. Our version is about 97% the same as the reported question.

Brazilian card transactions are registered as daily receivables. You are given two valid CSV strings.

  • transactionsCsv has header customer_id,merchant_id,payout_date,card_type,amount.
  • contractsCsv has header contract_id,merchant_id,payout_date,card_type,amount.

Aggregate transactions by (merchant_id, card_type, payout_date). Each contract buys only its stated amount from the matching merchant receivable. Create a contract-ID receivable for that amount and subtract it from the merchant receivable. Keep the merchant row when its remaining amount is positive; remove it when the remaining amount is zero.

Return CSV rows beginning with id,card_type,payout_date,amount. Sort the data rows by Unicode code points in ID, then card type, then payout date. When all three strings are equal, sort by amount numerically in ascending order. Write each output amount in base-10 notation without leading zeros.

Function

allocatePartialContracts(transactionsCsv: String, contractsCsv: String) → String[]

Examples

Example 1

transactionsCsv = "customer_id,merchant_id,payout_date,card_type,amount\ncust1,merchantA,2022-01-07,Visa,500"contractsCsv = "contract_id,merchant_id,payout_date,card_type,amount\ncontract1,merchantA,2022-01-07,Visa,200"return = ["id,card_type,payout_date,amount","contract1,Visa,2022-01-07,200","merchantA,Visa,2022-01-07,300"]

The contract buys 200 of the 500 receivable, leaving 300 under the merchant ID.

Example 2

transactionsCsv = "customer_id,merchant_id,payout_date,card_type,amount\nc1,m1,2024-01-01,Visa,300\nc2,m1,2024-01-01,Visa,250\nc3,m2,2024-01-02,MasterCard,700"contractsCsv = "contract_id,merchant_id,payout_date,card_type,amount\nk1,m1,2024-01-01,Visa,550"return = ["id,card_type,payout_date,amount","k1,Visa,2024-01-01,550","m2,MasterCard,2024-01-02,700"]

A full-amount contract removes the matching merchant receivable. The unrelated merchant remains.

Example 3

transactionsCsv = "customer_id,merchant_id,payout_date,card_type,amount\nc1,zeta,2024-02-01,Visa,100\nc2,alpha,2024-02-02,Amex,80"contractsCsv = "contract_id,merchant_id,payout_date,card_type,amount"return = ["id,card_type,payout_date,amount","alpha,Amex,2024-02-02,80","zeta,Visa,2024-02-01,100"]

With no contracts, both aggregates remain and are sorted by output ID.

Constraints

  • Each CSV contains its exact header followed by between 0 and 100000 data rows.
  • Fields contain no commas, line breaks, or surrounding whitespace.
  • Amounts are positive integers at most 10^9; every aggregate fits a signed 64-bit integer.
  • Each contract maps to exactly one aggregated merchant receivable, its amount does not exceed that receivable, and no two contracts map to the same receivable.

More Stripe Phone Screen questions

  • Business Account KYC Verification — Parts 1–5PHONE SCREEN · Seen Nov 2026
  • Financial Account LedgerOA · PHONE SCREEN · Seen Nov 2026
  • Merchant Matching, Parts 1–2: Shared Fields and Weighted ThresholdsPHONE SCREEN · Seen Nov 2026
  • Parse Boolean Rule ExpressionsPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Merchant Payout Scheduler, Part 2: Per-Merchant SchedulesPHONE SCREEN · Seen Nov 2026
  • Transaction Fee Calculator — Parts 1–2: Basic Fee Calculation and Conditional Fee RulesPHONE SCREEN · Seen Nov 2026
  • Render a Task Tree from CSV RowsPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Invoice / Payment ReconciliationPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Linked Merchants Within Two HopsPHONE SCREEN · Seen Nov 2026
  • Portfolio Valuation, Part 1PHONE SCREEN · Seen Nov 2026

Similar questions at other companies

  • Insert an Employee into an Organization HierarchyWaymo · PHONE SCREENWaymo interview questions
  • Common Words Across FilesMeta · PHONE SCREENMeta interview questions
  • Summarize Server Healthcheck LogsNVIDIA · PHONE SCREENNVIDIA interview questions
  • Transform Dotted Keys into a Nested MapProofpoint · ONSITE INTERVIEW
  • Serialize and Deserialize a String Key-Value StoreByteDance · ONSITE INTERVIEWByteDance interview questions
  • Deep Merge with a Conflict ResolverAutodesk · ONSITE INTERVIEWAutodesk interview questions
  • Number of AtomsAmazon · ONSITE INTERVIEW
  • Most Frequent Call Path From Function Trace LogsRoblox · PHONE SCREEN · ONSITE INTERVIEWRoblox interview questions
  • In-Memory Filesystem CommandsPerplexity AI · PHONE SCREEN · ONSITE INTERVIEWPerplexity AI interview questions
  • Top K Movies by Play Count from CSV DataTubi · PHONE SCREEN

Interview reports that mention this question

  • Stripe New Grad Interview Question Bank: 47 Problems

Stripe interview experiences

  • Stripe New Grad SWE OA and Phone Screen: 2 Experiences
  • Stripe Experienced SWE OA and Onsite Questions: 3 Experiences
  • Stripe SWE Intern Linked Merchants Team Screen: 1 Experience
  • Stripe OA: What It Tests (2026)
  • Stripe SWE Onsite over Two Days: 1 Experience
All Stripe interview questionsSee Stripe hiring insights
Saved
class Solution {
    public String[] allocatePartialContracts(String transactionsCsv, String contractsCsv) {
      // write your code here
    }
}
Checking account…