Article Vote Tracker
Updated
Problem statement
Build an in-memory vote-management service for an online news platform. Users may upvote or downvote published articles, and the service tracks the articles on which each user most recently changed their vote.
Process the operations in order and return one row for each operation that produces output.
Operations
["ADD", articleName]: add an article. Article IDs start at1and increase by one. Return the assigned ID as a one-element row.["UPVOTE", articleId, userId]: record an upvote. The article ID is valid, and any user ID is allowed.["DOWNVOTE", articleId, userId]: record a downvote. The article ID is valid, and any user ID is allowed.["LAST_THREE", userId]: return the titles of the last three distinct articles on which the user flipped their vote from upvote to downvote or from downvote to upvote. Return the most recent title first.
Casting the same vote repeatedly is not a flip. If a user flips the same article again, that article becomes the most recent entry and appears only once in the result.
Do not use persistent storage, and do not consider thread safety.
Function
processArticleVotes(operations: String[][]) → String[][]Examples
Example 1
operations = [["ADD","Alpha"],["ADD","Beta"],["ADD","Gamma"],["UPVOTE","1","u1"],["UPVOTE","2","u1"],["DOWNVOTE","1","u1"],["DOWNVOTE","2","u1"],["UPVOTE","1","u1"],["UPVOTE","3","u1"],["LAST_THREE","u1"]]return = [["1"],["2"],["3"],["Alpha","Beta"]]The first three rows are the assigned article IDs. Alpha and Beta both receive vote flips. Alpha is flipped again later, so it moves ahead of Beta. Gamma's first vote is not a flip.
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
- Stateful Paginated Fetch NLyft · PHONE SCREENLyft interview questions
- Recent Event Stream QueriesSnowflake · PHONE SCREENSnowflake interview questions
- Machine Message RouterOpenAI · PHONE SCREENOpenAI interview questions
- Metric Counter with a Fake ClockSnap Inc. · ONSITE INTERVIEWSnap Inc. interview questions
- Per-Client Sliding-Window Rate LimiterNike, Inc. · ONSITE INTERVIEWNike, Inc. interview questions
- Completions API Rate LimiterCursor · PHONE SCREENCursor interview questions
- Restaurant Waitlist with Exact-Size TablesGoogle · ONSITE INTERVIEWGoogle interview questions
- Dynamic Least-Loaded Job DispatcherCresta · PHONE SCREENCresta interview questions
- Key-Value Store GET and PUT QPSDatabricks · PHONE SCREENDatabricks interview questions
- Matching Engine with Order CancellationIMC Trading · ONSITE INTERVIEWIMC Trading interview questions
Interview reports that mention this question
- Rippling No-Level Onsite Loops: 24 Experiences (Part 5 of 6)
- Rippling No-Level Design, Screens: 30 Experiences (Part 2 of 6)
- Rippling SWE Interviews, No Level: 156 Experiences (Part 1 of 6)
- Rippling Senior SWE Onsite Loops: 15 Experiences (Part 6 of 12)
- Rippling Staff and SDE-2 Onsites: 21 Experiences (Part 8 of 12)
- Rippling KV and Music Screens: 33 Experiences (Part 4 of 12)