PracHub
QuestionsPremiumCoachesLearningGuidesInterview Prep
|Home/Coding & Algorithms/Google

Match payments to invoices by memo or amount

Last updated: Mar 29, 2026

Quick Overview

This Coding & Algorithms question for a Data Scientist evaluates string parsing and pattern matching, keyed and numeric record matching, date-based tie-breaking, and algorithmic complexity analysis, and is commonly asked to test handling of messy input formats and deterministic reconciliation rules.

  • Google
  • Coding & Algorithms
  • Data Scientist

Match payments to invoices by memo or amount

Company: Google

Role: Data Scientist

Category: Coding & Algorithms

Interview Round: Technical Screen

You are building a small payment-to-invoice matching utility. ### Data You are given: - `invoices`: a list of invoice records with: - `invoice_id` (string) - `amount_cents` (integer) - `due_date` (string, ISO-8601 date like `YYYY-MM-DD`) - `payments`: a list of payment records with: - `payment_id` (string) - `amount_cents` (integer) - `memo` (string; may contain extra whitespace) Assume `invoice_id` is unique in `invoices`. ### Part 1 (Memo → invoice_id matching) A payment memo may contain a standardized invoice reference in the form: - `"Paying off: <INVOICE_ID>"` where `<INVOICE_ID>` is the invoice id you should match to. Write a function that, for each payment, extracts the target `invoice_id` from the memo (if present), finds the corresponding invoice in `invoices`, and outputs a matched result. **Output requirement (per payment):** - If a match is found: output the `payment_id`, extracted `invoice_id`, and the matched invoice details. - If no match is found (or memo cannot be parsed): output a clear "not found" result for that payment. Handle edge cases such as extra spaces in the memo, missing/empty memo, or malformed standardized strings. ### Part 2 (Hybrid matching: memo-based OR amount-based) Extend the logic: 1) If `memo` contains the standardized prefix `"Paying off:"`, use Part 1 memo → `invoice_id` matching. 2) Otherwise, match by amount: - Find invoices where `invoice.amount_cents == payment.amount_cents`. - If there are multiple candidates, choose the invoice with the earliest `due_date`. - If there is no candidate, output: `"cannot find matching invoice for amount <amount_cents>"` (or equivalent). State the time and space complexity of your approach and justify it.

Quick Answer: This Coding & Algorithms question for a Data Scientist evaluates string parsing and pattern matching, keyed and numeric record matching, date-based tie-breaking, and algorithmic complexity analysis, and is commonly asked to test handling of messy input formats and deterministic reconciliation rules.

Related Interview Questions

  • Solve Rooms and Top-K Streams - Google (medium)
  • Find Containing Range - Google (medium)
  • Rearrange Tasks With Cooldown - Google (medium)
  • Implement Employee Management and Expression Evaluation - Google (medium)
  • Solve Three Array and Matrix Path Problems - Google (medium)
Google logo
Google
Oct 19, 2025, 12:00 AM
Data Scientist
Technical Screen
Coding & Algorithms
4
0

You are building a small payment-to-invoice matching utility.

Data

You are given:

  • invoices : a list of invoice records with:
    • invoice_id (string)
    • amount_cents (integer)
    • due_date (string, ISO-8601 date like YYYY-MM-DD )
  • payments : a list of payment records with:
    • payment_id (string)
    • amount_cents (integer)
    • memo (string; may contain extra whitespace)

Assume invoice_id is unique in invoices.

Part 1 (Memo → invoice_id matching)

A payment memo may contain a standardized invoice reference in the form:

  • "Paying off: <INVOICE_ID>"

where <INVOICE_ID> is the invoice id you should match to.

Write a function that, for each payment, extracts the target invoice_id from the memo (if present), finds the corresponding invoice in invoices, and outputs a matched result.

Output requirement (per payment):

  • If a match is found: output the payment_id , extracted invoice_id , and the matched invoice details.
  • If no match is found (or memo cannot be parsed): output a clear "not found" result for that payment.

Handle edge cases such as extra spaces in the memo, missing/empty memo, or malformed standardized strings.

Part 2 (Hybrid matching: memo-based OR amount-based)

Extend the logic:

  1. If memo contains the standardized prefix "Paying off:" , use Part 1 memo → invoice_id matching.
  2. Otherwise, match by amount:
    • Find invoices where invoice.amount_cents == payment.amount_cents .
    • If there are multiple candidates, choose the invoice with the earliest due_date .
    • If there is no candidate, output: "cannot find matching invoice for amount <amount_cents>" (or equivalent).

State the time and space complexity of your approach and justify it.

Submit Your Answer to Earn 20XP

Sign in to leave a comment

Loading comments...

Browse More Questions

More Coding & Algorithms•More Google•More Data Scientist•Google Data Scientist•Google Coding & Algorithms•Data Scientist Coding & Algorithms
PracHub

Master your tech interviews with 8,000+ 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.