FastPrepDriver Balance Ledger
Problems/Driver Balance Ledger

Driver Balance Ledger

Rippling logoRippling● EasyFULLTIMEPHONE SCREEN

Updated Sep 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The report preserves per-driver balance tracking, a frequently repeated total-balance query, and an emphasis on caching. It does not preserve the update methods, query signature, numeric limits, or the exact prefix-sum follow-ups; this operation-sequence version matches the reported core at about 65%.

Maintain an in-memory balance ledger for delivery drivers. Process each operation in order:

  • ["ADJUST", driverId, delta]: add the signed integer delta to the driver's current balance. A driver has balance 0 before the first adjustment.
  • ["BALANCE", driverId]: append the driver's current balance to the result. An unseen driver has balance 0.
  • ["TOTAL"]: append the sum of every driver's current balance to the result.

Only BALANCE and TOTAL operations produce output. Return those values in operation order.

The total-balance operation may be called very frequently, so it should not scan every driver on each call.

Function

processDriverBalances(operations: String[][]) → long[]

Examples

Example 1

operations = [["ADJUST","alice","1200"],["ADJUST","bob","800"],["TOTAL"],["BALANCE","alice"],["ADJUST","alice","-300"],["TOTAL"]]return = [2000,1200,1700]

After the first two adjustments, the total is 1200 + 800 = 2000. Alice's balance is 1200. Her final adjustment lowers both her balance and the cached total by 300, so the last result is 1700.

Example 2

operations = [["BALANCE","d7"],["TOTAL"],["ADJUST","d7","-50"],["BALANCE","d7"],["TOTAL"]]return = [0,0,-50,-50]

An unseen driver starts at 0, and an empty ledger also totals 0. Signed adjustments may make a balance and the overall total negative.

Example 3

operations = [["ADJUST","a","5"],["ADJUST","a","-5"],["ADJUST","b","9"],["TOTAL"],["BALANCE","a"],["BALANCE","b"]]return = [9,0,9]

Repeated adjustments accumulate for the same driver. Driver a returns to 0, while driver b contributes the entire total of 9.

Constraints

  • 1 <= operations.length <= 2 * 10^5.
  • Each operation has one of the documented forms.
  • Each driverId contains 1 to 40 ASCII letters, digits, hyphens, or underscores.
  • Each delta is a decimal integer string between -10^9 and 10^9, inclusive.
  • Every individual driver balance and the total balance fit in a signed 64-bit integer.

More Rippling Phone Screen questions

  • Filter, Sort, and Deduplicate Scheduled TasksPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Stateful Log Transform and SearchPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Dependency-Aware Task SchedulerPHONE SCREEN · Seen Nov 2026
  • Delivery Cost Tracker with Effective-Dated RatesPHONE SCREEN · Seen Nov 2026
  • Camel CardsPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Best and Worst Camel Card CompletionsPHONE SCREEN · Seen Nov 2026
  • Corporate Card Expense RulesOA · PHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • In-Memory Priority Task SchedulerPHONE SCREEN · Seen Oct 2026
  • Limit an Organization Tree's HeightPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Median Across N Sorted ArraysPHONE SCREEN · Seen Oct 2026

Similar questions at other companies

  • Config Store with Priority OverridesMicrosoft · PHONE SCREENMicrosoft interview questions
  • ID Allocator with Assign and ReleaseSnap Inc. · PHONE SCREENSnap Inc. interview questions
  • Feature Flag EvaluationCVS Health · PHONE SCREEN
  • In-Memory Key-Value Store OperationsOpenAI · PHONE SCREENOpenAI interview questions
  • LRU CacheAthenahealth · PHONE SCREEN
  • Design In-Memory File SystemSnowflake · PHONE SCREENSnowflake interview questions
  • LRU CacheApple · PHONE SCREEN · ONSITE INTERVIEWApple interview questions
  • Paged KV Cache AccessNVIDIA · PHONE SCREENNVIDIA interview questions
  • LRU Cache for Query ResultsAmazon · PHONE SCREEN · ONSITE INTERVIEW
  • In-Memory Filesystem CommandsPerplexity AI · PHONE SCREEN · ONSITE INTERVIEWPerplexity AI interview questions

Interview reports that mention this question

  • Rippling Delivery Cost Screen: 21 Experiences (Part 2 of 12)
  • Rippling Full-Time SWE Interviews: 224 Experiences (Part 1 of 12)

Rippling interview experiences

  • Rippling Senior SWE Full Loop Questions: 1 Experience
  • Rippling Experienced SWE Phone Screens: 2 Experiences
  • Rippling Design Rounds and Onsites: 17 Experiences (Part 3 of 3)
  • Rippling Phone Coding Screens: 14 Experiences (Part 2 of 3)
All Rippling interview questionsSee Rippling hiring insights
Saved
class Solution {
    public long[] processDriverBalances(String[][] operations) {
        // Write your code here.
    }
}
Checking account…