152: Сyclic graph
Given a number of nodes labeled from 0 to nodes - 1 and a list of edges, check does the graph has a cycle
Note: An
edgeis a pair of nodes
Example 1
Input: nodes = 4, edges = [[0, 1], [2, 3]]
Output: false
Explanation:
0-->1 2-->3
Example 2
Input: nodes = 3, edges = [[0, 1], [1, 2], [2, 0]]
Output: true