← Pinterest Interview InsightsSoftware Engineer

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

SeniorPrefer not to say
Jun 2026

Summary

Pinterest system design round focused on a graph connectivity problem using pins as nodes. The whole session revolved around one problem but went pretty deep into tradeoffs and scaling concerns.

Questions Asked (2)

Q1

Given a graph where pins are nodes and edges represent relationships like shared boards or users, how would you determine if two pins are connected? What data structures would you use, and how does your approach change at the scale of millions of pins and billions of edges?

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

Started with adjacency lists and BFS, which felt fine for small inputs.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by framing the problem as a graph connectivity query, then discuss the trade-offs between BFS/DFS for small-scale and union-find or distributed graph processing for large-scale. Emphasize that at Pinterest's scale, precomputation and indexing are essential to achieve low-latency responses.

Pro tip: Mention that connectivity queries are often part of a larger recommendation system, so caching frequent queries and using approximate methods for real-time suggestions can be a smart trade-off.

1. Clarify requirements and scale

Ask about the expected query patterns (e.g., real-time vs batch), latency requirements, and whether the graph is static or dynamic. Confirm the scale: millions of pins and billions of edges.

2. Choose basic data structures and algorithms

For small-scale, represent the graph as an adjacency list and use BFS/DFS to check connectivity. For dynamic connectivity, consider union-find with path compression and union by rank.

3. Address large-scale challenges

At scale, a single machine cannot hold the graph, so discuss distributed approaches like Pregel or GraphX for batch processing, or sharding the graph and using a distributed union-find. Precompute connected components and store them in a key-value store for fast lookups.

4. Optimize for performance and trade-offs

Discuss indexing connected components, caching frequent queries, and using approximate methods (e.g., Bloom filters) if exact connectivity is not always required. Consider the trade-off between precomputation cost and query latency.

5. Summarize and conclude

Recap the chosen approach, emphasizing how it meets the scale and latency requirements, and mention potential extensions like handling dynamic updates or incremental computation.

Key Points to Mention

  • Graph representation: adjacency list vs adjacency matrix, and their memory implications at scale.
  • BFS/DFS for small-scale connectivity, with time complexity O(V+E).
  • Union-Find (Disjoint Set Union) for dynamic connectivity, with optimizations like path compression and union by rank.
  • Distributed graph processing frameworks (e.g., Pregel, GraphX) for billion-edge graphs.
  • Precomputation of connected components and storage in a distributed key-value store (e.g., Redis, Cassandra) for low-latency queries.
  • Trade-offs between exact and approximate connectivity, and caching strategies for frequent queries.

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

Q2

How would you identify and list all connected components across the full pin graph?

Algorithms & Data StructuresSystem Design
Author's notes

Basically an extension of the first part.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the scale and nature of the pin graph (e.g., number of nodes/edges, whether it's static or dynamic) to choose between BFS/DFS for small graphs or distributed algorithms like connected components via MapReduce/Spark for large-scale. Then outline a step-by-step method: preprocess the graph, run the algorithm, and handle disconnected components and isolated nodes. Finally, discuss trade-offs and optimizations for Pinterest's scale.

Pro tip: Mention that Pinterest's pin graph is likely huge and sparse, so you'd use a distributed graph processing framework (e.g., GraphX, Giraph) or union-find with path compression in a distributed setting, and emphasize the importance of iterative pruning and checkpointing to handle failures.

1. Clarify Requirements and Scale

Ask about graph size, whether it's static or dynamic, and performance constraints (e.g., memory, time). This shows you understand the problem context before diving into solutions.

2. Choose Algorithm Based on Scale

For small graphs, use BFS/DFS from each unvisited node. For large-scale, propose distributed algorithms like connected components using label propagation or union-find with MapReduce/Spark.

3. Outline Implementation Details

Describe data structures (adjacency list, edge list) and how to handle isolated nodes. For distributed, explain partitioning, message passing, and convergence criteria.

4. Address Optimizations and Trade-offs

Discuss optimizations like union by rank, path compression, or iterative pruning. Compare BFS/DFS vs. union-find vs. distributed approaches in terms of time/space complexity.

5. Handle Edge Cases and Scalability

Mention handling disconnected components, large graphs that don't fit in memory, and potential failures in distributed systems (e.g., checkpointing, fault tolerance).

Key Points to Mention

  • BFS/DFS for small graphs with O(V+E) time complexity
  • Union-Find (Disjoint Set Union) with path compression and union by rank for near-linear time
  • Distributed graph processing frameworks (e.g., GraphX, Giraph, Pregel) for massive graphs
  • MapReduce/Spark implementations using label propagation or hash-to-min
  • Handling isolated nodes and ensuring all components are identified
  • Trade-offs between memory usage, time complexity, and implementation complexity

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