← rippling Interview Insights

rippling·Software Engineer·Onsite - System Design / Architecture·Senior

SeniorPrefer not to say
Jul 2026

Summary

Rippling SWE interview, system design round focused on a single in-memory data structure problem. The problem looked deceptively simple but the O(1) constraint on getLast3Flips is where things get interesting. No behavioral stuff, just the one question the whole time.

Questions Asked (1)

Q1

Design an in-memory voting system for articles where users can vote up, down, or clear their vote. Support operations to cast/update a vote, get an article's score (ups minus downs), and retrieve the last 3 flip events for an article. A flip is specifically a direct up-to-down or down-to-up change, not a clear. All three operations must run in O(1).

System DesignAlgorithms & Data StructuresData Modeling
Author's notes

The score part is easy, just maintain a counter per article and adjust it on each vote call.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the requirements and constraints, then propose a data model that tracks each user's current vote and the article's aggregate score. Use a per-article data structure to maintain the last 3 flip events in O(1) by storing them in a fixed-size circular buffer or deque. Walk through the operations to demonstrate O(1) time complexity for each.

Pro tip: Emphasize that flips are only direct up-to-down or down-to-up changes; clears should not be recorded as flips. Also, consider concurrency and idempotency, as real systems may have multiple users voting simultaneously.

1. Clarify Requirements and Constraints

Ask clarifying questions about user identification, vote persistence, concurrency, and whether the last 3 flips should be per user or per article. Confirm that all operations must be O(1) and that flips exclude clears.

2. Design Data Model

Propose storing a mapping from user ID to their current vote (up, down, or none) and an article-level score. For flip history, use a fixed-size circular buffer (or deque) per article to store the last 3 flip events.

3. Implement Operations

Detail how castVote updates the user's vote, adjusts the score, and conditionally records a flip if the new vote is the opposite of the old vote. Explain how getScore returns the stored score and getLastFlips returns the buffer contents.

4. Analyze Complexity

Show that each operation performs a constant number of steps: updating a hash map entry, adjusting an integer, and appending to a fixed-size buffer. Thus, all operations are O(1).

5. Discuss Edge Cases and Extensions

Cover scenarios like voting for the first time, clearing a vote, multiple users, and concurrency. Mention potential extensions like scaling to multiple articles or persisting data.

Key Points to Mention

  • Use a hash map (or dictionary) to store each user's current vote for O(1) lookup and update.
  • Maintain an integer score per article, incrementing/decrementing based on vote changes.
  • Record flips only when the vote changes directly from up to down or down to up; clears are not flips.
  • Use a fixed-size circular buffer (or deque) to store the last 3 flip events per article, ensuring O(1) insertion and retrieval.
  • Ensure all operations (castVote, getScore, getLastFlips) have constant time complexity by avoiding loops or scans.
  • Consider thread safety and idempotency if the system is concurrent.

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.