Reported September 2024
Microsoftgraph

Check Path Presence

Reported by candidates from Microsoft's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.

Get StealthCoderRuns invisibly during the live Microsoft OA. Under 2s to a working solution.
Founder's read

Microsoft's 'Check Path Presence' question hit the OA circuit in September 2024, and it's a graph problem that looks deceptively simple until you realize the edge cases. You're given some form of nodes and edges, and you need to determine whether a path exists between two points. This is a classic BFS or DFS setup, but the trick is usually in how the graph is represented or whether you're checking directed vs. undirected edges. StealthCoder can pattern-match this instantly if you blank on the traversal logic.

Pattern and pitfall

The core pattern here is graph connectivity, typically solved with either depth-first search or breadth-first search. You'll build an adjacency list from the input, then traverse from a source node to check if you can reach a target. The common pitfall is forgetting to track visited nodes, which causes infinite loops on cyclic graphs. Another trap is mishandling the graph representation itself, especially if Microsoft's version uses an unusual input format. The trick often hinges on whether the graph is directed or undirected, and whether you need to validate that nodes actually exist before searching. When you're live in the OA and the logic isn't clicking, StealthCoder reads the problem constraints and feeds you the exact traversal approach without you typing it from scratch.

If this hits your live OA and you blank, StealthCoder solves it in seconds, invisible to the proctor.

If this hits your live OA

You can drill Check Path Presence 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 would have shipped this the night before his JPMorgan OA if he'd had it.

Get StealthCoder

Related leaked OAs

⏵ Practice the LeetCode equivalent

This OA pattern shows up on LeetCode as number of provinces. If you have time before the OA, drill that.

⏵ The honest play

You've seen the question. Make sure you actually pass Microsoft's OA.

Microsoft reuses patterns across OAs. Built by an Amazon engineer who would have shipped this the night before his JPMorgan OA if he'd had it. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Check Path Presence FAQ

Is this problem asking for any path or the shortest path?+

Microsoft's version typically asks for existence only, not optimality. BFS and DFS both work equally well for that. If the problem explicitly asks for shortest path length, you must use BFS. Read the output requirement carefully in the first 30 seconds.

How do I handle disconnected components?+

If the graph has multiple disconnected regions and your source is in one component but the target is in another, there's no path. Your traversal will naturally return false. Make sure you're not trying to visit the entire graph when you only need to check reachability from one node.

What's the visited set trick everyone talks about?+

You mark nodes as visited as you explore them to avoid processing the same node twice. Without it, you'll loop infinitely on cycles. Use a set or a boolean array indexed by node ID. This is non-negotiable for Microsoft's version.

Does it matter if I use recursion (DFS) or a queue (BFS)?+

For pure path existence, no. Both have O(V + E) complexity. Pick whichever you're faster with live. Recursion is shorter code but risks stack overflow on huge graphs. Queue is safer and slightly clearer under pressure.

What if the input uses a weird graph format I haven't seen?+

Parse it into an adjacency list first, even if it takes 2 minutes. Once you have that, the traversal is always the same. Microsoft sometimes encodes graphs as edge lists or adjacency matrices. Normalize it in your head before coding.

Problem reported by candidates from a real Online Assessment. Sourced from a publicly-available candidate-aggregated repository. Not affiliated with Microsoft.

OA at Microsoft?
Invisible during screen share
Get it