← Pinterest Interview Insights

Pinterest·Software Engineer·Technical Phone Screen·Intermediate

IntermediatePrefer not to say
May 2026

Summary

Pinterest coding round focused on a graph-based access control problem. The design angle made it feel more like a mini system design than a pure algorithms question, which I wasn't fully expecting.

Questions Asked (2)

Q1

Design and implement an access control API for a directed graph of resources. Specifically, implement grantAccess(from, to) and hasAccess(user, resource), where access propagates transitively along directed edges.

Algorithms & Data StructuresSystem DesignTechnical Trade-offs
Author's notes

Started with BFS on hasAccess and felt pretty good about it until they pushed on what happens when the graph gets large and hasAccess is called constantly.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

First, clarify the requirements: is the graph static or dynamic? What are the expected query patterns? Then, model the access control as reachability in a directed graph. For grantAccess, add a directed edge from 'from' to 'to'. For hasAccess, perform a reachability query from user to resource. Discuss trade-offs between precomputing transitive closure (fast queries, slow updates) and on-the-fly traversal (slow queries, fast updates), and propose a hybrid approach if needed.

Pro tip: Mention that in real systems, access control often involves more than simple reachability—consider inheritance, negative permissions, and revocation. Also, discuss how to handle cycles and ensure scalability with caching or incremental updates.

1. Clarify Requirements

Ask about graph size, update frequency, query frequency, and whether access can be revoked. Determine if the graph is static or dynamic, and if there are constraints like cycles.

2. Choose Data Structures

Represent the graph using adjacency lists (e.g., HashMap<Node, Set<Node>>) for efficient edge addition and traversal. For precomputed reachability, consider a transitive closure matrix or bitsets.

3. Implement grantAccess

Add a directed edge from 'from' to 'to'. If using precomputation, update the transitive closure incrementally (e.g., for all ancestors of 'from', add all descendants of 'to').

4. Implement hasAccess

If using on-the-fly traversal, perform BFS/DFS from user to resource. If using precomputed closure, do a constant-time lookup. Discuss caching frequent queries.

5. Discuss Trade-offs and Optimizations

Compare time/space complexity of approaches. For dynamic graphs, consider incremental algorithms or hybrid approaches. Address scalability, concurrency, and persistence.

Key Points to Mention

  • Graph representation: adjacency list vs. adjacency matrix
  • Reachability algorithms: BFS/DFS vs. transitive closure (Floyd-Warshall, bitset optimization)
  • Trade-offs: query time vs. update time vs. space
  • Handling cycles and ensuring termination in traversal
  • Caching strategies for frequent queries
  • Concurrency and consistency in a distributed setting

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

Q2

How would you handle revoking access in this system, and what are the trade-offs between computing reachability on the fly versus maintaining a precomputed closure?

Technical Trade-offsSystem DesignAlgorithms & Data Structures
Author's notes

Revocation is where I got exposed.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the system's requirements: scale, consistency needs, and access patterns. Then compare on-the-fly reachability computation (e.g., graph traversal) with precomputed closure (e.g., materialized transitive closure), discussing trade-offs in latency, storage, and update cost. Finally, propose a hybrid or adaptive solution based on the specific context.

Pro tip: Emphasize that the choice depends on the read/write ratio and consistency requirements; for Pinterest's scale, a hybrid approach with caching and incremental updates often balances performance and freshness.

1. Clarify Requirements

Ask about scale, read/write patterns, consistency needs, and latency SLAs to ground your answer in the specific system.

2. Explain Revocation Handling

Describe how revocation works in each model: on-the-fly checks traverse the graph per request, while precomputed closure updates the stored closure upon revocation.

3. Compare Trade-offs

Discuss latency, storage, update cost, and consistency: on-the-fly is simple but slow for deep graphs; precomputed is fast for reads but expensive to update and store.

4. Propose a Solution

Recommend a hybrid approach, such as caching reachability results with TTL and invalidating on revocation, or using incremental updates for the closure.

5. Address Edge Cases

Mention handling of cycles, large fan-outs, and eventual consistency, and how to monitor and adapt the solution over time.

Key Points to Mention

  • Graph traversal algorithms (BFS/DFS) for on-the-fly reachability
  • Transitive closure computation and materialization (e.g., via DFS or matrix multiplication)
  • Time and space complexity: O(V+E) per query vs O(V^2) storage for closure
  • Update cost: on-the-fly requires no updates; precomputed requires recomputation or incremental maintenance
  • Caching strategies and TTL to balance freshness and performance
  • Hybrid approaches: e.g., precompute for hot paths, on-the-fly for cold paths

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