Try to apply the union find approach given in the editorial to the following test case or graph : Total no of nodes = 4, edges : 1 -> 2, 4 -> 2, 3 -> 4, 3 -> 1. Clearly, the expected output is false since it doesn’t contain any cycle (run the test case with “see the expected output”…even that verifies it). but when I run this as custom input on the union find code given in the editorial, it gives the wrong answer as 1 or true.

# Who else realizes that the UNION FIND SOLUTION given in the editorial is NOT CORRECT!

**khushirajpal**#2

Absolutely, a union find solution work for an undirected graph , for a directed graph we have to use DFS