← All problemsSign in

TREES IN GRAPH

After solving lot of problems on graphs and trees chef thought to try something new. He came across a problem named TREES IN GRAPH. You are given a directed graph $G$ of $N$ nodes and $M$ edges. The nodes of $G$ are labeled with unique integer numbers as $[1, 2, ... , N]$. It's guaranteed that no multiple edges or self-loops appear in the graph. The graph has some properties as follows. - Nodes

HINT LADDERno hints yet
L1 Observation
L2 Technique
L3 Approach
L4 Pseudo-code
🔒
L5 Full solution
L5 unlocks only if you insist twice
solution.cppC++17

CodeSearch Tutor

Hints, not spoilers — it won’t hand over the full solution unless you insist.

voice by Sarvam AI

Sign in to chat with the tutor and save your progress.

Sign in to start