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.
Design and implement a data structure to track users’ votes (upvote/downvote) on articles.
Implement functions/methods with the following behavior:
vote(userId, articleId, voteType)
where
voteType ∈ {UP, DOWN}
getLastVotes(userId)
(articleId, voteType, timestamp-or-order)
.