Oracle Interview Question

cyclic graph question from leetcode