Find the First Day Each Checking Account Overdraws

Last updated: November 29, 2026

Quick Overview

Given opening balances and an unsorted list of (account, date, amount in cents) postings, return for every account the first date whose end-of-day balance is negative.

Bank of America
Coding & Algorithms
Software Engineer
Bank of America
November 29, 2026
Software Engineer
Phone Screen
Coding & Algorithms
Easy

0

0

0 solved


Given opening balances and an unsorted list of (account, date, amount in cents) postings, return for every account the first date whose end-of-day balance is negative.

A phone screen problem tied to consumer deposits, where overdraft decisions and Balance Connect transfers are based on end-of-day posted balances. The interviewer checks grouping, sorting, integer money handling and whether you ask what 'end of day' means before coding.

What the Interviewer Expects
  • Clarify that the rule is end-of-day balance, not intraday
  • Group postings by account and date, net them per day
  • Use integer cents, never floats
  • Handle accounts with an opening balance but no postings
  • State complexity and memory use
Key Topics to Cover
Hash maps
Sorting
Prefix sums
Money as integers
Deposit accounts
How to Approach This
  1. Clarify input constraints and edge cases before writing code.
  2. Walk through your approach verbally and confirm with the interviewer before coding.
  3. Start with a brute force solution, then optimize. Mention time and space complexity.
  4. Test your solution with examples, including edge cases like empty input or duplicates.
  5. Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
  • How would the answer change if the bank posted credits before debits within a day?
  • How would you stream this if postings arrive in date order across millions of accounts?
  • How would you also return the most negative balance reached?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice DSA Problems
Sample Answer
Requirements

Inputs: opening maps account to cents; txns is a list of (account, ISO date, signed cents) in any order. For each account, apply each day's net postings in date order and report the first date who...

High-Level Design

Two passes. First, aggregate postings into account then date then net cents, so intraday ordering does not matter (the rule is end-of-day). Second, for each account walk its dates in sorted order with...


Submit Your Answer
Markdown supported

Related Questions