Virus Spread (Intuit India)
Reported by candidates from Intuit's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.
You've got a Virus Spread problem from Intuit's February 2024 OA, and it's a classic breadth-first-search pattern wrapped in infection mechanics. The setup is straightforward: cells or nodes start infected, spread to neighbors over time, and you need to either count the infected, find when all are infected, or determine if containment is possible. Intuit's version likely tests whether you can model the spread correctly and traverse the graph layer by layer. StealthCoder reads the specifics in real time and feeds you the BFS scaffold if you blank on the traversal order.
Pattern and pitfall
Virus Spread is BFS because infection spreads outward in waves. Start with infected nodes in a queue, then process them level by level, marking neighbors as newly infected each iteration. The trick is tracking which step each node gets infected so you can answer questions like 'what's the minimum time' or 'how many are infected after T steps'. A common pitfall is mixing up DFS (which will give you wrong timing) or forgetting to mark visited nodes, causing infinite loops or double-counts. Intuit likely gives you a grid or graph, initial infected positions, and asks for a count or a time. If you freeze on the order of operations, StealthCoder provides the queue-based pattern instantly so you can code without guessing.
Memorize the pattern. If you can't, run StealthCoder. The proctor sees the IDE. They don't see what's behind it.
You can drill Virus Spread (Intuit India) 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. Made by an engineer who treats the OA as theater. If yours is tonight, you don't have time to grind. You have time to hedge.
Get StealthCoderRelated leaked OAs
This OA pattern shows up on LeetCode as number of islands. If you have time before the OA, drill that.
You've seen the question.
Make sure you actually pass Intuit's OA.
Intuit reuses patterns across OAs. Made by an engineer who treats the OA as theater. If yours is tonight, you don't have time to grind. You have time to hedge. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Virus Spread (Intuit India) FAQ
Is this really just BFS, or is there a trick?+
It's BFS. The trick is recognizing that infection spreads in discrete time steps, not all at once. Track the step counter inside your loop. If Intuit adds obstacles or walls, you still BFS around them. No hidden math or greedy shortcut.
How do I handle the grid or adjacency list representation?+
Check the input format. If it's a grid, neighbors are up/down/left/right (4-directional) or 8-directional. If it's a graph, use the adjacency list given. Code both directions once, reuse the neighbor logic. This saves 10 minutes of debugging.
What if the problem asks for time-to-infect-all or infected-cell-count?+
Same BFS. For time, return the maximum step value when all cells are processed. For count, return the number of visited nodes. Both require you to iterate through the queue and track state. Don't overthink it.
Can I use DFS instead of BFS?+
No. DFS doesn't respect time steps, so you'll get wrong answers for timing-based queries. BFS guarantees you process nodes in the order they're reached, which models infection spread correctly.
How long do I have to code this?+
BFS is 15-25 lines of clean code. If you're familiar with the pattern, you'll write it in 5-10 minutes. If you blank, that's why you have a safety net. Practice the template once before the OA starts.