Minimum Clicks Between Wiki Pages
Reported by candidates from Snowflake's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.
You're looking at a graph traversal problem from Snowflake's May 2026 OA. The setup is straightforward: build an adjacency list from directed edges, then find the shortest path from start to target. The trick is recognizing this as a textbook breadth-first search problem. You're not optimizing; you're just finding the minimum hops. If you blank on BFS during the live OA, StealthCoder will surface the pattern and a working template in seconds.
The problem
Complete the function below. The function receives the full standard input as a single string and must return the exact standard output lines for the described problem. Problem Minimum Clicks Between Wiki Pages with Link Fetch Simulator You have a set of wiki pages where each page may link to other pages. You must implement a link fetch simulator and then compute the minimum number of clicks needed to navigate from start to target (one click follows one outgoing link). Tasks Implement get_links(page): return the list of pages directly reachable from page. Using get_links, compute the minimum clicks from start to target: If start == target, the answer is 0 If target is unreachable, return -1 Input (for this simulator-based problem) Line 1: integer m, number of directed links Next m lines: two strings u v meaning a link from u to v Last line: two strings start target get_links(page) should behave as: return all x such that an input edge page -> x exists. Output One line: the minimum click count, or -1 Constraints 1 <= m <= 2*10^5 Page names are whitespace-free strings Sample Tests (5) Input: 5 A B B C A D D C C E A C Output: 2 Input: 3 A B B C C D A D Output: 3 Input: 2 A B C D A D Output: -1 Input: 1 A A Output: 0 Input: 4 A B A C B D C D A D Output: 2 Example Input 5 A B B C A D D C C E A C Output 2 Function Description Complete solveMinimumWikiClicks. It has one parameter, String input, containing the full stdin payload. Return the stdout payload as an array of lines, without trailing newline characters. The returned string array must match the expected standard output lines for the sample input. Use the limits and requirements stated in the prompt.
Reported by candidates. Source: FastPrep
Pattern and pitfall
The problem disguises itself as a 'wiki simulator' but it's pure graph shortest-path. Parse m edges into an adjacency list by calling get_links conceptually (or building it directly). Then run BFS from start: queue the start node, track visited pages, and count depth. When you hit target, return the depth. If the queue empties before you find target, return -1. The edge cases are trivial: start equals target returns 0, unreachable returns -1. Most candidates overthink the 'simulator' framing and miss that BFS is the only real algorithm here. StealthCoder will cut through that noise and show you a clean BFS skeleton you can adapt in under two minutes.
If you see this problem in your OA tomorrow, the play is to recognize the pattern in 30 seconds. StealthCoder buys you that recognition.
You can drill Minimum Clicks Between Wiki Pages cold, or you can hedge it. StealthCoder runs invisibly during screen share and surfaces a working solution in under 2 seconds. The proctor sees the IDE. They don't see what's behind it. Built by an Amazon engineer who passed his OA cold and still thinks the filter is broken.
Get StealthCoderRelated leaked OAs
You've seen the question.
Make sure you actually pass Snowflake's OA.
Snowflake reuses patterns across OAs. Built by an Amazon engineer who passed his OA cold and still thinks the filter is broken. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Minimum Clicks Between Wiki Pages FAQ
Is this really just BFS?+
Yes. The 'link fetch simulator' language is noise. You build an adjacency list from the edges, then BFS from start to target counting depth. It's unweighted, so BFS guarantees minimum clicks. No Dijkstra, no fancy optimizations needed.
What's the gotcha everyone hits?+
Forgetting to check if start equals target before running BFS. Also, some candidates build the graph incorrectly and miss that these are directed edges. A-to-B is not the same as B-to-A. Reread the input format carefully.
How do I parse the input?+
First line is m (edge count). Next m lines are pairs of page names (strings). Last line is start and target. Parse each edge into a dictionary keyed by source page. The value is a list of destination pages. Then BFS.
Do I need to handle disconnected components?+
Yes. If target is not reachable from start, return -1. BFS will naturally handle this: if the queue empties without finding target, you've exhausted all reachable nodes and target isn't among them.
How long should this take to code?+
Five to eight minutes if you recognize BFS immediately. Input parsing takes a minute or two. Graph building takes another minute. BFS itself is ten to fifteen lines. Don't overthink the 'simulator' framing; it's just a graph problem.