Converging Maze: Largest Sum Cycle
Reported by candidates from Juspay's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.
Juspay's Converging Maze problem hits you with a graph traversal wrapped in a sum-finding layer. You're looking for the largest sum cycle in a directed graph, which means you need to identify cycles and compute their total weight. The catch is that cycles in directed graphs require careful state tracking. BFS alone won't find them, but you'll likely combine traversal with cycle detection. This is the kind of problem where a single misstep in your cycle-detection logic tanks your solution. StealthCoder will catch the pattern if you freeze mid-implementation.
Pattern and pitfall
The trick here is that BFS finds shortest paths and connected components, but cycles need cycle-detection logic (tracking visited states and recursion stacks, or using DFS to mark back edges). You're building on graph fundamentals: you traverse, detect when you revisit a node in the current path, sum the nodes in that cycle, and track the maximum. The pitfall is confusing 'visited globally' with 'visited in the current DFS path,' which breaks cycle detection. Many candidates implement BFS for traversal but miss the actual cycle-finding mechanism. The pattern is really DFS with backtracking plus sum aggregation, even though the hint says BFS. StealthCoder surfaces this discrepancy instantly if you're coding a traversal that doesn't close the cycle-detection loop.
If this hits your live OA and you blank, StealthCoder solves it in seconds, invisible to the proctor.
You can drill Converging Maze: Largest Sum Cycle 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 StealthCoderRelated leaked OAs
You've seen the question.
Make sure you actually pass Juspay's OA.
Juspay 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.
Converging Maze: Largest Sum Cycle FAQ
Do I need to find all cycles or just the largest one?+
Just the largest. So you detect cycles as you traverse, sum each one, and keep a running maximum. You don't need to enumerate or store every cycle. Track the max and return it at the end.
What's the difference between a global visited set and a recursion stack in cycle detection?+
Global visited marks nodes you've ever touched. Recursion stack marks nodes in your current DFS path. A back edge (edge to a recursion-stack node) signals a cycle. Global visited alone misses cycles because you can reach a node via multiple paths.
Will BFS alone solve this?+
No. BFS is for shortest paths and level-order traversal. Cycle detection in directed graphs requires DFS and tracking the recursion stack. The hint may be a red herring or test whether you recognize that DFS is required here.
How do I sum the nodes in a detected cycle?+
When you find a back edge, trace backwards from the current node to the target node using your parent/predecessor map. Sum all nodes in that segment. Store the sum and continue traversing to find larger cycles.
Is there a time-limit trap here?+
Potentially. Naive cycle detection is O(V + E) per cycle, and you might revisit paths. Use memoization on subproblems or limit your search space. If you time out, you're likely re-computing cycles instead of caching results.