Google phone screen

Anonymous User
406
Apr 09, 2025

Imagine we are a software development company and we manage our dev process using an issue tracking tool. Each issue has an ID and also a list of IDs of issues which block it (Blockers or parents). As a result we have 1 or multiple unidirectional graphs because there could have several root issues (Epics).

At some point in time someone added an issue A as a Blocker of issue B. But because A was already blocked by the descendants of the current issue B (descendants of B are the issues that are transitively blocked by B), this created a circular dependency. After this our UI issue tracking tool (Taskflow) stopped showing issues correctly. Our task is to find out all circular dependency loops.

The input is a 2D boolean array of blockers assignments. The row number is the issue ID. The column number is Blocker issue ID. So entry (i, j) is True means that issue i is blocked by issue j.
Example input:

0 1 2
0 False False True
1 True False False
2 False True False

The output is a list of dependency cycles. The order inside one cycle doesn't matter.
Example:
[
[0, 2, 1] (as well can be 2,1,0 or 1,0,2)
]

I try to DFS but messed up. Please any solution?..

Comments (7)