Snowflake: Web crawler: fewest clicks between pages, then the actual path
Problem. You have a helper, get_all_links(page), that returns the outgoing links of a page. Given a start page and a target page, return the minimum number of clicks needed to get from the start to the target.
Variant. Return the shortest path itself (the list of pages), not just its length.
Follow-ups.
- What could go wrong if
get_all_linksfails or responds slowly? The candidate talked about throttling, network bandwidth, slow responses and ways to mitigate them. - For the path variant, can you reduce memory use? The interviewer also asked about rebuilding the path by backtracking, for example through parent pointers, instead of storing every full path in the queue.
- Multithreading was not raised in this round.
What the interviewer cared about. Clean BFS reasoning, complexity analysis, and thinking about an external API that can fail. Writing code was optional for the last part, and only about five minutes were left. This was the second of two back-to-back coding rounds for an entry-level role.
Comments 0
No comments yet. Ask the author something, or add what happened in your own round.