All challenges
Multiple ChoiceHard 30s

Cycle Detection

In a directed graph, cycle detection is cleanest with:
Options
  1. 1BFS only, marking each node on dequeue
  2. 2Sorting all edges by weight first
  3. 3DFS with a recursion stack (colors)
  4. 4A hash of node values seen so far

Think you can answer under pressure?

Get matched and answer live questions in 3-minute 1v1 battles. Elo ranking, badge tiers and bragging rights on the line.

Play this in a 3-minute battle