← Pinterest Interview Insights

Pinterest·Software Engineer·Technical Phone Screen·Intermediate

Intermediate
May 2026

Summary

Pinterest SWE interview with a graph connectivity problem that sounds deceptively simple until you realize the board co-membership angle makes the implicit graph pretty interesting to reason about. One round, mostly algorithmic.

Questions Asked (1)

Q1

You have a set of boards, each containing pins, and a list of direct pin-to-pin edges. Two pins are also considered adjacent if they appear on the same board. Given two pins, determine whether they are connected, and if so, return the shortest path length between them.

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

The board co-membership part is what gets you.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Model the problem as an unweighted graph where each pin is a node, and edges exist between pins that are directly connected or share a board. Then run BFS from the source pin to find the shortest path length to the target pin, returning -1 if unreachable. Emphasize that BFS guarantees the shortest path in unweighted graphs.

Pro tip: Mention that you can optimize by precomputing board memberships and using a visited set to avoid cycles, and discuss how this scales if the graph is huge (e.g., using bidirectional BFS or partitioning).

1. Clarify the problem and constraints

Ask about input size, whether boards can have many pins, if edges are bidirectional, and if multiple boards can share pins. Confirm that adjacency includes same-board pins.

2. Model as a graph

Represent each pin as a node. Add edges for direct pin-to-pin connections and for every pair of pins on the same board (or use a board node to avoid O(n^2) edges).

3. Choose BFS for shortest path

Since edges are unweighted, BFS from the source pin gives the shortest path length. Use a queue and a visited set to track distances.

4. Handle edge cases and complexity

Consider if source equals target (distance 0), disconnected components (return -1), and analyze time/space complexity. Discuss trade-offs of explicit vs implicit graph representation.

5. Discuss optimizations and system design

For large-scale systems, mention bidirectional BFS, precomputation, caching, or distributed graph processing. Relate to Pinterest's scale and real-time constraints.

Key Points to Mention

  • Graph representation: adjacency list vs. board nodes to avoid quadratic edge creation
  • BFS guarantees shortest path in unweighted graphs
  • Time complexity: O(V + E) where V is pins and E is edges (direct + same-board)
  • Space complexity: O(V + E) for adjacency and visited set
  • Handling disconnected graphs and returning -1
  • Scalability considerations: bidirectional BFS, caching, distributed processing

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