Design a Social Network Class with Follow Relationships and Versioned Snapshots
Design a Social Network class that tracks follower relationships between users. Implement the following operations: follow(userA, userB), unfollow(userA, userB), snapshot() which captures the current state and returns a snapshot ID, isFollow(userA, userB, snapshotId) to query whether a follow relationship existed at a given snapshot, getFollowees(userId, snapshotId) to retrieve users that a given user followed at a snapshot, and getUsersFollowed(userId, snapshotId) to retrieve users who followed a given user at a snapshot.
Asked at:
Question Timeline
See when this question was last asked and where, including any notes left by other candidates.
Early July, 2026
Staff
Mid June, 2026
Staff
Early May, 2026
Staff
Design a Social Network class that can be used to track what user follows what user. Implement functionalities like: follow(userA, userB) unfollow(userA, userB) snapshot() // Takes a snapshot of the current state and returns ID. isFollow(userA, userB, snapshotId) getFollowees(userId, snapshotId) getUsersFollowed(userId, snapshotId)
Hello Interview Premium
Your account is free and you can post anonymously if you choose.