Oracle interview question

cyclic graph question from leetcode