This question evaluates a candidate's object-oriented design skills, ability to model many-to-many follow relationships, and handling of edge cases such as self-follow semantics and idempotent follow/unfollow operations.
Design a small set of classes for a social product where users can follow and unfollow each other.
getFollowers(user)
→ all users who follow
user
getFollowing(user)
→ all users whom
user
follows
isFollowing(a, b)
→ whether user
a
follows user
b
isMutual(a, b)
→ whether
a
follows
b
and
b
follows
a
userId
.