Design an in-memory data structure for voting on articles.
Users can vote on an article with either:
A flip is when a user changes their vote from up→down or down→up (clearing a vote is not a flip).
Implement the following operations efficiently:
vote(user_id, article_id, new_vote)
new_vote
is one of
{UP, DOWN, NONE}
.
getScore(article_id)
(up_count - down_count)
for the article.
getLast3Flips(article_id)
{user_id, from_vote, to_vote, timestamp_or_sequence}
.
vote
: O(1)
getScore
: O(1)
getLast3Flips
: O(1)