FastPrepStore Dispatch with Selector Subscriptions
Problems/Store Dispatch with Selector Subscriptions

Store Dispatch with Selector Subscriptions

Rippling logoRippling● MediumFULLTIMEPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Every rule here is our choice. The state is 100 numbered fields that start at 0, and each subscriber's selected value is the sum of the fields it picked. A dispatch sets one or more fields at once, and a subscriber is told only when its sum differs from the sum just before that dispatch, so a dispatch that writes the same values again, or leaves a sum unchanged, tells that subscriber nothing. Told subscribers are listed in the order they joined, where joining again counts from the latest subscribe, and a subscribe returns the current sum. The operation-list format, the names, the limits and the examples are ours too.

The report names one task from a first-round frontend interview: build a pub-sub state store of the kind Redux uses, where a component reads a selected value through a hook and sends changes through dispatch. The report gives no state shape, selector rule, rule for when to notify, signature or examples, so this is a thin source and most of the task is our design.

This version checks who is told after each dispatch. It cannot check the JavaScript side: a store object whose subscribe hands back an unsubscribe function, or a React hook that re-renders a component. The editorial covers that.

Our version is about 35% the same as the reported question.

Build a tiny state store with subscribers, like the store behind a frontend app. The state has 100 number fields, numbered 0 to 99, and every field starts at 0. Each subscriber picks some fields and watches their sum, which is its selected value. A subscriber is told about a dispatch only when its selected value changes.

Process the operations in order and return one list for each operation:

  • "subscribe" with args[i] = [id, f1, f2, ...]: subscriber id starts watching fields f1, f2, .... Return a list that holds its current selected value.
  • "unsubscribe" with [id]: subscriber id stops watching. Return an empty list.
  • "dispatch" with [f1, v1, f2, v2, ...]: set field f1 to v1, field f2 to v2, and so on, all at once. Return the ids of the current subscribers whose selected value after the dispatch differs from their selected value just before it, in the order they subscribed. Return an empty list if no selected value changed.

A subscriber that unsubscribes and later subscribes again counts as a new subscriber: its place in the order comes from its latest subscribe, and it may watch different fields.

Function

runStore(operations: String[], args: int[][]) → int[][]

Examples

Example 1

operations = ["subscribe","subscribe","dispatch","dispatch","dispatch","subscribe","unsubscribe","dispatch"]args = [[1,0,1],[2,1],[0,5],[0,4,1,1],[1,1],[3,0],[1],[0,7]]return = [[0],[0],[1],[2],[],[4],[],[3]]

Subscriber 1 watches fields 0 and 1, and subscriber 2 watches field 1; both start at 0. Setting field 0 to 5 changes only subscriber 1's sum (0 to 5). The next dispatch sets field 0 to 4 and field 1 to 1 together: subscriber 1's sum stays 4 + 1 = 5, so only subscriber 2 (0 to 1) is told. Setting field 1 to 1 again changes nothing. Subscriber 3 joins and sees field 0, which is 4. After subscriber 1 leaves, setting field 0 to 7 tells only subscriber 3.

Example 2

operations = ["subscribe","subscribe","dispatch","unsubscribe","subscribe","dispatch"]args = [[5,2],[3,2],[2,1],[5],[5,2,3],[2,9]]return = [[0],[0],[5,3],[],[1],[3,5]]

Subscriber 5 joined before subscriber 3, so the first change lists 5 first. Subscriber 5 then leaves and joins again watching fields 2 and 3, which counts as a new, later subscription. So the last change lists 3 before 5.

Example 3

operations = ["subscribe","dispatch","dispatch"]args = [[8,0,1,2],[0,-3,1,3],[2,0]]return = [[0],[],[]]

Fields 0 and 1 become -3 and 3 in one dispatch, so the sum stays 0 and nobody is told. Setting field 2 to the 0 it already holds changes nothing either.

Constraints

  • 1 <= operations.length <= 1000 and args.length == operations.length
  • Each operations[i] is "subscribe", "unsubscribe" or "dispatch".
  • For "subscribe", 2 <= args[i].length <= 6: an id, then 1 to 5 different fields. For "unsubscribe", args[i].length == 1. For "dispatch", args[i].length is 2, 4, 6, 8 or 10, and the fields in it are all different.
  • Every id is between 1 and 10^6, every field is between 0 and 99, and every value is between -10^6 and 10^6.
  • "subscribe" uses an id that is not subscribed at that moment, and "unsubscribe" uses an id that is.

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

  • LRU Cache for Query ResultsAmazon · PHONE SCREEN · ONSITE INTERVIEW
  • In-Memory Filesystem CommandsPerplexity AI · PHONE SCREEN · ONSITE INTERVIEWPerplexity AI interview questions
  • Rectangle Point Coverage CountsOpenAI · PHONE SCREEN · ONSITE INTERVIEWOpenAI interview questions
  • File Storage ServiceCresta · PHONE SCREENCresta interview questions
  • Return Every Matching DecryptionDuolingo · PHONE SCREENDuolingo interview questions
  • Corporation Reporting LinesMicrosoft · PHONE SCREENMicrosoft interview questions
  • Key-Value Store on a Block DeviceLambda · PHONE SCREEN
  • LRU Key-Value Cache OperationsCohesity · PHONE SCREEN
  • Fixed-Window Rate LimiterProofpoint · PHONE SCREEN
  • LRU CacheApple · PHONE SCREEN · ONSITE INTERVIEWApple interview questions

Interview reports that mention this question

  • Rippling Frontend, Mobile, Data: 18 Experiences (Part 12 of 12)

Rippling interview experiences

  • Rippling No-Level Older Reports: 31 Experiences (Part 6 of 6)
  • Rippling No-Level Onsite Loops: 24 Experiences (Part 5 of 6)
  • Rippling No-Level Screens and Loops: 18 Experiences (Part 4 of 6)
  • Rippling No-Level Coding Screens: 37 Experiences (Part 3 of 6)
  • Rippling No-Level Design, Screens: 30 Experiences (Part 2 of 6)
All Rippling interview questionsSee Rippling hiring insights
Saved
class Solution {
    public int[][] runStore(String[] operations, int[][] args) {
        // Write your code here.
    }
}
Checking account…