Loading page…
A payments app must count the streaks of a 100,000-entry ledger that add up to a disputed payout, where refunds are negative. Adding up every streak makes about 5 billion additions. The sum of a streak is the difference of two running totals, so a hash map from running total to how often it occurred turns each entry into one lookup. Start the table with total 0, look up before storing, and a sliding window cannot do this with negative entries.
A payments app keeps a ledger for each merchant.