Design follow/follower classes
Company: Uber
Role: Software Engineer
Category: Software Engineering Fundamentals
Difficulty: medium
Interview Round: Technical Screen
## Object-Oriented Design: Follow / Followers Relationship
Design a small set of classes for a social product where users can **follow** and **unfollow** each other.
### Requirements
- Each user can follow many other users.
- Each user can be followed by many other users.
- Support querying:
- `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`
- Handle edge cases:
- following yourself (decide behavior)
- repeated follow/unfollow calls should be idempotent
### Constraints (assume)
- You may assume all users are already created and identified by a unique `userId`.
- You may choose in-memory data structures; optionally discuss how this maps to persistence.
Quick Answer: 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.