← Google Interview Insights

Google·Software Engineer·Technical Phone Screen·Senior

Senior
Jul 2026

Summary

Google SWE interview with a group expense splitting problem. The core task was computing minimal debt settlements, which sounds straightforward until you realize the 'minimal transactions' part is the whole puzzle.

Questions Asked (1)

Q1

Given a list of shared expenses where each expense has a payer, a total amount, and a list of people splitting it equally, compute the minimum number of money transfers needed to settle all debts among the group.

Algorithms & Data StructuresTechnical Trade-offs
Author's notes

I started by computing net balances per person, which was fine.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the problem constraints and edge cases, then propose a two-phase solution: first compute each person's net balance, then use a greedy algorithm to match the largest creditor with the largest debtor to minimize transfers. Discuss the optimality of the greedy approach and potential trade-offs with alternative methods like subset-sum or flow-based solutions.

Pro tip: Mention that while the greedy algorithm is not always optimal for minimizing transfers (it's NP-hard in general), it is optimal for many practical cases and is the standard approach in real-world systems like Splitwise. This shows awareness of theoretical limits and practical engineering trade-offs.

1. Clarify Requirements

Ask about constraints: number of people, number of expenses, whether amounts are integers or floats, and if the goal is absolute minimum transfers or a good approximation. Confirm that transfers can be between any two people.

2. Compute Net Balances

For each person, calculate how much they paid minus their share of each expense. This yields a net balance: positive means they are owed money, negative means they owe money.

3. Design Algorithm

Propose a greedy approach: repeatedly match the person with the maximum positive balance (creditor) with the person with the maximum negative balance (debtor), transfer the minimum of the absolute values, and update balances. Continue until all balances are zero.

4. Analyze Complexity and Optimality

Explain that the greedy algorithm runs in O(n log n) with a priority queue or O(n^2) with simple sorting, and that it minimizes the number of transfers in many cases but is not guaranteed to be optimal. Mention that finding the absolute minimum is NP-hard (related to partition problem).

5. Discuss Trade-offs and Extensions

Compare with alternative approaches like subset-sum or linear programming, and discuss practical considerations: rounding errors, transaction fees, and whether to allow multi-party transfers. Conclude with why the greedy approach is often preferred in practice.

Key Points to Mention

  • Net balance calculation: sum of payments made minus sum of shares owed.
  • Greedy matching of largest creditor and largest debtor to reduce the number of transfers.
  • Time complexity: O(n log n) with a max-heap, or O(n^2) with sorting.
  • Optimality: Greedy is not always optimal; exact minimization is NP-hard (subset-sum reduction).
  • Edge cases: zero balances, floating-point precision, and people with no net debt.
  • Real-world application: similar to algorithms used in expense-sharing apps like Splitwise.

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