Find the Shortest Click Path with a Fallible Link API

Read the full interview experience this question came from →

Quick Overview

Find the minimum click distance and a shortest URL path using a fallible outgoing-link API. The solution covers BFS correctness, cycles, predecessor memory, deterministic ties, bounded concurrency, throttling, retries, caching, incomplete results, cancellation, and resumable crawling.

Find the Shortest Click Path with a Fallible Link API

Company: Snowflake

Role: Software Engineer

Category: Software Engineering Fundamentals

Difficulty: medium

Interview Round: Technical Screen

# Find the Shortest Click Path with a Fallible Link API You are given `getAllLinks(url)`, which returns the outgoing links from a page. Given `startUrl` and `targetUrl`, first return the minimum number of link clicks needed to reach the target. Then extend the design to return one shortest path. Discuss a memory-conscious path-reconstruction strategy and production concerns when `getAllLinks` can be slow, rate-limited, or fail. Assume links form a directed graph and the graph may contain cycles. ### Clarifying Questions to Ask - Does the API return a stable, deduplicated order, and how are equivalent URLs canonicalized? - What result is required when the target is unreachable or an API call remains unavailable after retries? - Is any shortest path acceptable, or must ties be deterministic? - May requests run concurrently, and what rate or bandwidth limits apply? ### Part 1 — Minimum click count Explain the graph traversal, visited-state timing, and stopping condition that produce the minimum number of clicks. #### What This Part Should Cover - Breadth-first layers over directed links. - Marking a canonical URL visited when it is enqueued. - Returning zero when start and target are the same and a defined unreachable result otherwise. ### Part 2 — Return a shortest path Show how to recover a path and compare a predecessor map with a lower-memory approach that reruns or backtracks through distance information. #### What This Part Should Cover - Correct predecessor assignment on first discovery. - Reversing the target-to-start chain. - The memory versus additional calls or traversal trade-off of avoiding a full predecessor map. ### Part 3 — Make link fetching robust Describe bounded concurrency, throttling, retry, timeout, caching, and failure semantics for `getAllLinks`. #### What This Part Should Cover - A global and per-host request budget. - Retry only for suitable transient failures, with backoff and jitter. - Durable or in-memory caching that does not confuse a failed fetch with an empty page. - Cancellation of unnecessary frontier work after the shortest target layer is resolved. ### What a Strong Answer Covers - Preserves BFS shortest-path correctness despite cycles and parallel fetching. - Defines URL identity and deterministic tie behavior when required. - Separates “no outgoing links” from “links could not be fetched.” - Quantifies network, memory, and latency trade-offs rather than proposing unbounded parallelism. ### Follow-up Questions 1. How would you produce the lexicographically smallest shortest path if API results arrive out of order? 2. What state must be checkpointed to resume after the crawler process crashes? 3. When can bidirectional search help, given that the API exposes only outgoing links?

Overview: Find the minimum click distance and a shortest URL path using a fallible outgoing-link API. The solution covers BFS correctness, cycles, predecessor memory, deterministic ties, bounded concurrency, throttling, retries, caching, incomplete results, cancellation, and resumable crawling.

Read the full Snowflake Software Engineer interview experience this question came from

|Home/Software Engineering Fundamentals/Snowflake
Snowflake logo
Snowflake
Sep 3, 2026
mediumSoftware EngineerTechnical ScreenSoftware Engineering Fundamentals
2
0

You are given getAllLinks(url), which returns the outgoing links from a page. Given startUrl and targetUrl, first return the minimum number of link clicks needed to reach the target. Then extend the design to return one shortest path.

Discuss a memory-conscious path-reconstruction strategy and production concerns when getAllLinks can be slow, rate-limited, or fail. Assume links form a directed graph and the graph may contain cycles.

Clarifying Questions to Ask Guidance

  • Does the API return a stable, deduplicated order, and how are equivalent URLs canonicalized?
  • What result is required when the target is unreachable or an API call remains unavailable after retries?
  • Is any shortest path acceptable, or must ties be deterministic?
  • May requests run concurrently, and what rate or bandwidth limits apply?

Part 1 — Minimum click count

Explain the graph traversal, visited-state timing, and stopping condition that produce the minimum number of clicks.

What This Part Should Cover Guidance

  • Breadth-first layers over directed links.
  • Marking a canonical URL visited when it is enqueued.
  • Returning zero when start and target are the same and a defined unreachable result otherwise.

Part 2 — Return a shortest path

Show how to recover a path and compare a predecessor map with a lower-memory approach that reruns or backtracks through distance information.

What This Part Should Cover Guidance

  • Correct predecessor assignment on first discovery.
  • Reversing the target-to-start chain.
  • The memory versus additional calls or traversal trade-off of avoiding a full predecessor map.

Describe bounded concurrency, throttling, retry, timeout, caching, and failure semantics for getAllLinks.

What This Part Should Cover Guidance

  • A global and per-host request budget.
  • Retry only for suitable transient failures, with backoff and jitter.
  • Durable or in-memory caching that does not confuse a failed fetch with an empty page.
  • Cancellation of unnecessary frontier work after the shortest target layer is resolved.

What a Strong Answer Covers Guidance

  • Preserves BFS shortest-path correctness despite cycles and parallel fetching.
  • Defines URL identity and deterministic tie behavior when required.
  • Separates “no outgoing links” from “links could not be fetched.”
  • Quantifies network, memory, and latency trade-offs rather than proposing unbounded parallelism.

Follow-up Questions Guidance

  1. How would you produce the lexicographically smallest shortest path if API results arrive out of order?
  2. What state must be checkpointed to resume after the crawler process crashes?
  3. When can bidirectional search help, given that the API exposes only outgoing links?
Loading comments...