PracHub
QuestionsPremiumLearningGuidesCheatsheetNEWCoaches
|Home/Software Engineering Fundamentals/Uber

Design follow/follower classes

Last updated: Mar 29, 2026

Quick Overview

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.

  • medium
  • Uber
  • Software Engineering Fundamentals
  • Software Engineer

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.

Related Interview Questions

  • Design a Real-Time Top-K Ranking System - Uber (hard)
  • Design a Parking Lot - Uber (medium)
  • Design a Parking Garage Object Model - Uber (medium)
  • Design a meeting room reservation API - Uber (medium)
  • Design a Rolling Event Counter - Uber (medium)
Uber logo
Uber
Mar 1, 2026, 12:00 AM
Software Engineer
Technical Screen
Software Engineering Fundamentals
9
0
Loading...

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.

Solution

Show

Comments (0)

Sign in to leave a comment

Loading comments...

Browse More Questions

More Software Engineering Fundamentals•More Uber•More Software Engineer•Uber Software Engineer•Uber Software Engineering Fundamentals•Software Engineer Software Engineering Fundamentals
PracHub

Master your tech interviews with 7,500+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.