PracHub
QuestionsPremiumLearningGuidesInterview PrepNEWCoaches
|Home/Coding & Algorithms/Google

Compute minimal transfers to settle group expenses

Last updated: Mar 29, 2026

Quick Overview

This question evaluates the ability to compute per-person net balances and optimize peer-to-peer payments to minimize the total number of transactions, exercising algorithmic reasoning, numeric bookkeeping under equal-split constraints, and efficiency for larger inputs.

  • medium
  • Google
  • Coding & Algorithms
  • Software Engineer

Compute minimal transfers to settle group expenses

Company: Google

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Technical Screen

## Problem A group of friends go on a trip and share expenses. Each expense is recorded as an object: - `payer` (string): who paid the full amount - `amount` (integer): total amount paid (assume in cents to avoid floating point) - `payees` (string[]): the friends who should share this expense **equally** Each payee owes an equal share of that expense. The payer may also appear in `payees` (meaning they also consume/share the expense). ### Task Given an array of such expenses, compute a set of **money transfers between friends** that settles all debts: - After applying your transfers, every person’s net balance becomes 0 (no one owes/is owed). - The transfers should be **minimal** in the sense of using the **fewest number of payments/transactions** possible. - If multiple minimal answers exist, returning any one is acceptable. ### Output format Return an array of transfer objects: - `payer`: the person who sends money (the debtor) - `amount`: the amount sent (integer, in cents) - `payees`: an array containing exactly **one** person who receives the money (the creditor) Example transfer: `{ payer: "bob", amount: 1000, payees: ["alice"] }` meaning “bob pays alice 1000 cents”. ### Example **Input** ```js [ { payer: 'alice', amount: 4000, payees: ['bob', 'jess', 'alice', 'sam'] }, { payer: 'jess', amount: 2000, payees: ['jess', 'alice'] } ] ``` **Output (one valid minimal answer)** ```js [ { payer: 'bob', amount: 1000, payees: ['alice'] }, { payer: 'sam', amount: 1000, payees: ['alice'] } ] ``` ### Notes / Constraints - `amount` is divisible by `payees.length` (so equal splitting is exact). - Names are case-sensitive strings. - You may assume the input size is large enough that an efficient solution is expected.

Quick Answer: This question evaluates the ability to compute per-person net balances and optimize peer-to-peer payments to minimize the total number of transactions, exercising algorithmic reasoning, numeric bookkeeping under equal-split constraints, and efficiency for larger inputs.

Related Interview Questions

  • Solve Flower Placement and Directory Deletion - Google (medium)
  • Compute Turnstile Crossing Times - Google (hard)
  • Simulate In-Place Cellular State Updates - Google (hard)
  • Determine Whether a Word Exists in a Graph - Google (medium)
  • Implement Checksums and Feature Rollout Evaluation - Google (medium)
Google logo
Google
Nov 16, 2025, 12:00 AM
Software Engineer
Technical Screen
Coding & Algorithms
6
0

Problem

A group of friends go on a trip and share expenses. Each expense is recorded as an object:

  • payer (string): who paid the full amount
  • amount (integer): total amount paid (assume in cents to avoid floating point)
  • payees (string[]): the friends who should share this expense equally

Each payee owes an equal share of that expense. The payer may also appear in payees (meaning they also consume/share the expense).

Task

Given an array of such expenses, compute a set of money transfers between friends that settles all debts:

  • After applying your transfers, every person’s net balance becomes 0 (no one owes/is owed).
  • The transfers should be minimal in the sense of using the fewest number of payments/transactions possible.
  • If multiple minimal answers exist, returning any one is acceptable.

Output format

Return an array of transfer objects:

  • payer : the person who sends money (the debtor)
  • amount : the amount sent (integer, in cents)
  • payees : an array containing exactly one person who receives the money (the creditor)

Example transfer: { payer: "bob", amount: 1000, payees: ["alice"] } meaning “bob pays alice 1000 cents”.

Example

Input

[
  { payer: 'alice', amount: 4000, payees: ['bob', 'jess', 'alice', 'sam'] },
  { payer: 'jess', amount: 2000, payees: ['jess', 'alice'] }
]

Output (one valid minimal answer)

[
  { payer: 'bob', amount: 1000, payees: ['alice'] },
  { payer: 'sam', amount: 1000, payees: ['alice'] }
]

Notes / Constraints

  • amount is divisible by payees.length (so equal splitting is exact).
  • Names are case-sensitive strings.
  • You may assume the input size is large enough that an efficient solution is expected.

Comments (0)

Sign in to leave a comment

Loading comments...

Browse More Questions

More Coding & Algorithms•More Google•More Software Engineer•Google Software Engineer•Google Coding & Algorithms•Software Engineer Coding & Algorithms
PracHub

Master your tech interviews with 7,500+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.