← Pinterest Interview Insights

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

SeniorPrefer not to say
Apr 2026

Summary

Pinterest system design round focused on a graph connectivity problem using pins as nodes. The discussion got pretty deep into tradeoffs between different data structures and query patterns, which I wasn't fully prepared for at that scale.

Questions Asked (2)

Q1

Given a graph where pins are nodes and edges represent shared boards or user interactions, how would you determine if two pins are connected? What data structures would you use, and how does your approach change between one-time queries versus repeated online queries?

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

Started with adjacency lists which felt right, then they pushed on union-find and I fumbled explaining the path compression part under pressure.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by modeling the problem as a graph connectivity query, then discuss algorithms like BFS/DFS for one-time queries and Union-Find for repeated queries. Emphasize trade-offs between preprocessing time, query time, and memory, and how to scale for Pinterest's large graph.

Pro tip: Mention that in practice, you'd likely use a distributed graph processing system (e.g., GraphX, Giraph) or a precomputed index for online queries, and discuss how to handle dynamic updates to the graph.

1. Clarify requirements and assumptions

Ask about graph size, whether it's static or dynamic, query frequency, and latency requirements. Clarify if connectivity is transitive (e.g., via shared boards) and if direction matters.

2. Choose data structures for graph representation

Use adjacency list for sparse graphs (common in social networks) or adjacency matrix for dense graphs. For Union-Find, use parent and rank arrays.

3. One-time query approach

For a single query, use BFS or DFS from one pin to check if the other is reachable. Time complexity O(V+E), space O(V).

4. Repeated online queries approach

Preprocess the graph to answer connectivity queries efficiently. Use Union-Find (Disjoint Set Union) with path compression and union by rank for near O(1) query time after O(E α(V)) preprocessing. Alternatively, compute connected components once and store component IDs.

5. Discuss trade-offs and scalability

Compare BFS/DFS vs Union-Find in terms of preprocessing, query time, and memory. For dynamic graphs, consider incremental Union-Find or more complex structures. For massive graphs, discuss distributed processing or approximate methods.

Key Points to Mention

  • Graph representation: adjacency list vs adjacency matrix
  • BFS/DFS for one-time connectivity queries
  • Union-Find (Disjoint Set Union) with path compression and union by rank for repeated queries
  • Connected components precomputation and component ID lookup
  • Trade-offs: preprocessing time vs query time, memory usage, and scalability
  • Handling dynamic updates and distributed graph processing for large-scale systems

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

Q2

How would you scale this pin connectivity solution to handle millions of pins and billions of edges? Walk through the architectural decisions you'd make.

System DesignTechnical Trade-offsData Modeling
Author's notes

This is where it got real.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the requirements and scale (e.g., read/write ratio, latency, consistency needs), then propose a high-level architecture that partitions data and uses appropriate storage and caching layers. Walk through trade-offs for each component, focusing on how to handle billions of edges efficiently while maintaining performance and scalability.

Pro tip: Emphasize that scaling is iterative: start with a simple design that meets current needs, then identify bottlenecks and evolve the architecture. Mention specific Pinterest technologies like PinGraph or Zen to show domain awareness.

1. Clarify Requirements and Scale

Ask questions to understand the expected read/write patterns, latency requirements, consistency needs, and data access patterns (e.g., traversals, lookups). This ensures your design targets the right problems.

2. High-Level Architecture

Propose a distributed system with separate storage for pins and edges, using sharding and replication. Consider using a graph database or a custom edge store optimized for billions of edges.

3. Data Partitioning and Sharding

Explain how to partition data (e.g., by user ID, pin ID, or edge type) to distribute load evenly and enable horizontal scaling. Discuss strategies like consistent hashing and avoiding hotspots.

4. Storage and Indexing

Choose appropriate storage engines (e.g., wide-column stores like Cassandra for edges, KV stores for pins) and indexing strategies (e.g., composite keys, secondary indexes) to support efficient queries.

5. Caching and Performance Optimization

Implement multi-level caching (e.g., CDN, application-level cache, database cache) and consider denormalization or materialized views for frequent queries. Discuss trade-offs between consistency and performance.

Key Points to Mention

  • Sharding strategies (e.g., by user ID or pin ID) and consistent hashing to distribute load.
  • Choice of storage: wide-column stores (Cassandra) for edges, KV stores (Redis) for caching, and possibly a graph database for complex traversals.
  • Caching layers: CDN for static content, Memcached/Redis for hot data, and query result caching.
  • Data modeling: adjacency lists vs. edge tables, and how to index for efficient lookups (e.g., composite keys).
  • Trade-offs: consistency vs. availability (CAP theorem), latency vs. cost, and normalization vs. denormalization.
  • Monitoring and auto-scaling: use metrics to detect hotspots and scale horizontally; consider async processing for writes.

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