← Stripe Interview Insights

Stripe·Software Engineer·Onsite - System Design / Architecture·Senior

Senior
Jun 2026

Summary

Stripe system design screen for a software engineer role, focused entirely on a role-based access control problem with a twist around hierarchical account inheritance. The question had a lot of moving parts and the discussion went pretty deep into indexing tradeoffs and complexity analysis.

Questions Asked (1)

Q1

You have a list of (userId, accountId, role) assignments and an account hierarchy where roles inherit downward from ancestors. Given an accountId and a set of required roles, return all users who hold every required role on that account, either directly or through inheritance. Walk through your indexing strategy, how you'd traverse ancestors, and the time complexity.

System DesignAlgorithms & Data StructuresTechnical Trade-offs
Author's notes

This one took me a minute to fully parse.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the data model and constraints, then propose an indexing strategy that maps users to roles per account and precomputes ancestor relationships for efficient traversal. Walk through the algorithm step-by-step, analyzing time and space complexity, and discuss trade-offs between precomputation and on-the-fly traversal.

Pro tip: Mention that role inheritance can be modeled as a DAG and that precomputing transitive closures (e.g., via DFS/BFS) enables O(1) ancestor checks, but be prepared to discuss memory vs. latency trade-offs.

1. Clarify Requirements and Data Model

Ask about the size of the data, update frequency, and whether the hierarchy is a tree or DAG. Confirm that roles inherit downward and that a user can have multiple roles.

2. Design Indexing Strategy

Propose indexes: a map from (accountId, role) to a set of userIds for direct assignments, and a precomputed ancestor list for each account (or a way to traverse ancestors efficiently).

3. Traverse Ancestors and Collect Users

For the given account, traverse its ancestors (including itself) and for each required role, collect the union of users who have that role directly on any ancestor. Then intersect these sets to find users with all roles.

4. Analyze Complexity and Trade-offs

Discuss time complexity: O(A * R * U) where A is number of ancestors, R required roles, U average users per role. Space complexity for indexes. Compare with alternative approaches like on-the-fly traversal or using bitsets.

5. Handle Edge Cases and Optimizations

Consider cycles in hierarchy, empty required roles, users with no roles, and optimizations like caching results or using inverted indexes for fast intersection.

Key Points to Mention

  • Modeling the account hierarchy as a tree or DAG and precomputing ancestor relationships (e.g., via DFS/BFS) for O(1) ancestor lookup.
  • Using inverted indexes: mapping (accountId, role) to a set of userIds for direct assignments.
  • Efficient set intersection algorithms (e.g., using hash sets or bitsets) to find users with all required roles.
  • Time complexity analysis: O(A * R * U) where A is ancestors, R required roles, U users per role; space complexity for indexes.
  • Trade-offs between precomputation (faster queries, more memory) and on-the-fly traversal (slower queries, less memory).
  • Handling dynamic updates: if hierarchy or assignments change frequently, consider incremental updates or caching strategies.

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.