You are managing a system that needs to execute n distinct processes, labeled from 0 to n - 1.
You're given a list called dependencies, where dependencies[i] = [a, b] means that Process a depends on Process b, i.e., Process b must complete before Process a can begin.
Your task is to determine whether it is possible to execute all processes given their dependencies.
For example, the pair [0, 1] indicates that Process 0 depends on Process 1, meaning Process 1 must be executed before Process 0 can begin.
Return true if all processes can be executed successfully without any circular dependencies. Otherwise, return false if there is a cycle that makes it impossible to resolve all process dependencies.
numProcesses = 3
dependencies = [[1, 0], [2, 1]]
numProcesses = 3
dependencies = [[0, 1], [1, 2], [2, 0]]