← Pinterest Interview Insights

Pinterest·Software Engineer·Technical Phone Screen·Intermediate

Intermediate
Jun 2026

Summary

Pinterest SWE interview with a group expense settlement problem. Pretty classic balance-sheet style coding question but the edge cases kept me on my toes longer than I'd like to admit.

Questions Asked (1)

Q1

Given a list of group trip transactions where each transaction has a payer, a total amount, and a list of people splitting the cost equally, compute a minimal (or any valid) set of direct transfers that brings everyone's net balance to zero.

Algorithms & Data StructuresTechnical Trade-offs
Author's notes

I got the basic structure pretty fast: compute each person's net balance by adding what they paid and subtracting their share of each transaction.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the problem: compute each person's net balance by summing what they paid minus their share of each transaction. Then, to minimize transfers, use a greedy two-pointer approach on sorted balances (creditors and debtors) to settle debts, or if any valid set is acceptable, simply match each debtor with a creditor. Discuss trade-offs between minimal transfers (NP-hard in general) and practical greedy solutions.

Pro tip: Mention that minimizing the number of transactions is equivalent to the NP-hard partition problem, so in practice a greedy approach that settles largest debts first is optimal enough and runs in O(n log n). This shows you understand both theory and real-world engineering constraints.

1. Clarify requirements and assumptions

Ask whether the goal is minimal transfers or any valid set, and confirm that all amounts are in the same currency and divisible to the smallest unit. Also clarify if a person can both owe and be owed (net balance).

2. Compute net balances

For each transaction, add the total amount to the payer's balance and subtract each participant's equal share. After processing all transactions, each person has a net balance (positive = should receive, negative = should pay).

3. Choose an algorithm for settling

If minimal transfers are required, note that it's NP-hard and propose a greedy heuristic: sort balances, then repeatedly match the largest creditor with the largest debtor. If any valid set is fine, simply pair each debtor with a creditor until all balances are zero.

4. Implement and handle edge cases

Write code to compute balances and generate transfers. Handle floating-point precision by using integers (e.g., cents) and ensure the sum of balances is zero. Consider empty transactions or single-person groups.

5. Analyze complexity and trade-offs

Discuss time complexity: O(T + P log P) for sorting balances, where T is transactions and P is people. Mention that the greedy approach may not yield the absolute minimum transfers but is efficient and practical.

Key Points to Mention

  • Net balance calculation: sum(paid) - sum(owed) for each person.
  • Greedy two-pointer algorithm: sort balances, match largest creditor and debtor.
  • NP-hardness of minimizing transactions (related to partition problem).
  • Handling floating-point precision by using integer cents.
  • Time and space complexity: O(T + P log P) time, O(P) space.
  • Edge cases: zero balances, single participant, rounding errors.

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.