Implement an article voting tracker
Company: Rippling
Role: Software Engineer
Category: Coding & Algorithms
Difficulty: easy
Interview Round: Technical Screen
## Coding: Article Voting Tracker
Design and implement a data structure to track users’ votes (upvote/downvote) on articles.
### Operations
Implement functions/methods with the following behavior:
1. `vote(userId, articleId, voteType)` where `voteType ∈ {UP, DOWN}`
- Track the user’s vote on the article.
- **If the user repeats the same vote on the same article** (e.g., UP then UP again), it should be **counted only once** (i.e., do not record a new vote event).
- **If the user changes their vote** on the same article (e.g., UP then DOWN, or DOWN then UP), it **should be counted as a new vote event**.
2. `getLastVotes(userId)`
- Return (or print) the user’s **last 3 vote events**, most recent first.
- Each returned event should include at least: `(articleId, voteType, timestamp-or-order)`.
### Notes / constraints
- Assume many users and articles.
- The focus is on correct behavior and efficient operations.
- Define and handle edge cases (e.g., user has < 3 vote events; unknown user).
Quick Answer: This question evaluates a candidate's ability to design efficient stateful data structures and algorithms for tracking user votes, including correct handling of idempotent repeated votes, vote changes, deduplication, and retrieval of the most recent events.