FastPrepBank Account Balances (Part 2): Monthly Reconciliation
Problems/Bank Account Balances (Part 2): Monthly Reconciliation

Bank Account Balances (Part 2): Monthly Reconciliation

Stripe logoStripe● MediumFULLTIMENEW GRADPHONE SCREEN
QuestionFunctionExamplesConstraints

Problem statement

Source note: About 90% source match for the reported Part 2 task. The report asks for a target-month comparison of two CSV inputs and a bank/account/end-date/balance report labeled Match or Not Match. The second input schema was not fully recalled. The shared five-column schema, month selection by end date, one record per account per month, missing-record handling, bounds, and output ordering are practice details.

This is Part 2 of the bank balance exercise. Part 1 is Latest Bank Account Balance. Solve this part directly from its two CSV inputs; it does not take Part 1's result as input.

You receive two sets of bank account balance records, primaryRows and comparisonRows, and a target month in YYYY-MM form. Each data row uses these five fields:

bank,account,startDate,endDate,balance

Build a balance reconciliation report for the target month. For every bank account with a primary record in that month, find the record for the same bank, account, and month in the comparison input. If both balances are equal, label the row Match. If the comparison record is missing or its balance differs, label it Not Match.

Return one CSV string for every qualifying primary record, using this output format:

bank,account,endDate,balance,Match

Use Not Match instead of Match for an unmatched row. The output date and balance come from the primary record. Compare balances, not the two files' exact start or end dates. Ignore records from other months or years, and do not emit accounts found only in the comparison input. Sort the result by bank name and then account name in ascending lexicographic order.

For this practice version, both inputs contain data rows without a header and use the same five-column schema. A row belongs to the calendar month of its endDate; periods need not be whole calendar months. Each input has at most one record per bank/account/calendar-month, so no latest-record selection is needed within the target month. Treat bank and account names as case-sensitive strings, preserving leading zeros. Balances are signed integers, not amounts to sum. Return an empty array if the primary input has no record in the target month.

Function

reconcileMonthlyBalances(primaryRows: String[], comparisonRows: String[], month: String) → String[]

Examples

Example 1

primaryRows = ["HSBC,123456,2021-12-01,2021-12-31,150","HSBC,123456,2019-05-01,2019-05-31,200","BA,566376374,2021-12-01,2021-12-31,300"]comparisonRows = ["HSBC,123456,2021-12-01,2021-12-31,150","BA,566376374,2021-12-01,2021-12-31,250"]month = "2021-12"return = ["BA,566376374,2021-12-31,300,Not Match","HSBC,123456,2021-12-31,150,Match"]

HSBC has the same December 2021 balance in both inputs. BA has different balances. The older HSBC row is ignored, and output is sorted by bank and account.

Example 2

primaryRows = ["BANK,001,2022-01-01,2022-01-31,-5","BANK,002,2022-01-01,2022-01-31,0"]comparisonRows = ["BANK,001,2021-12-28,2022-01-15,-5","OTHER,003,2022-01-01,2022-01-31,10"]month = "2022-01"return = ["BANK,001,2022-01-31,-5,Match","BANK,002,2022-01-31,0,Not Match"]

Account 001 matches despite different date endpoints because both records belong to January and balances agree. Account 002 has no comparison record. The comparison-only account is omitted.

Example 3

primaryRows = ["HSBC,123456,2020-12-01,2020-12-31,150"]comparisonRows = ["HSBC,123456,2021-12-01,2021-12-31,150"]month = "2021-12"return = []

The primary row is in December 2020, not December 2021. There is no primary record for the target month.

Constraints

  • Each input contains 0 to 100000 data rows.
  • Bank and account names have 1 to 20 ASCII letters, digits, hyphens, or underscores.
  • Every row has exactly five comma-separated fields with no surrounding spaces and no header.
  • Dates are valid ISO dates between 1900 and 2099 with startDate <= endDate; month is a valid YYYY-MM in that range.
  • Each balance is a canonical decimal integer between -1000000000 and 1000000000.
  • Within each input, there is at most one row for a given bank/account/endDate calendar month.

More Stripe problems

  • Portfolio Valuation, Part 1PHONE SCREEN · Seen Nov 2026
  • Chat Billing CalculationOA · Seen Nov 2026
  • Deployment Window SchedulerOA · Seen Nov 2026
All Stripe interview questionsSee Stripe hiring insights
Saved
class Solution {
    public String[] reconcileMonthlyBalances(String[] primaryRows, String[] comparisonRows, String month) {
        // Write your solution here.
    }
}
Checking account…