Free beta: free to use with daily limits while we build. Join the waitlist for founding-member pricing at launch. Join the waitlist

Sign up free

OpenAI interview question

Design data structures to store follow relationships with follow and unfollow

Company:
OpenAI
Type:
Coding
Difficulty:
Medium
Reported:
November 18, 2026

Problem

Design and implement the data structures for a social product that stores follow relationships between users and supports two operations:

  • follow(follower, followee): follower starts following followee.
  • unfollow(follower, followee): follower stops following followee.

Only these two operations are stated. Which read queries the product needs, and how repeated follows, unfollows of a missing relationship and self-follows behave, are open points to settle with the interviewer.

Example 1

Input: follow(u1, u2), follow(u1, u3), follow(u2, u1), unfollow(u1, u2)
Output: stored relationships u1 -> u3 and u2 -> u1

The unfollow removes the u1 to u2 relationship; the other two remain.

Constraints

  • Not stated; ask the interviewer.

Reported by candidates or drawn from publicly available sources, and rewritten in our own words. Pathwise Prep does not publish confidential assessment content. Report a concern