Cs50 Tideman Solution Link

: Iterate through your sorted pairs. For each pair, check if locking it (setting locked[i][j] = true ) would create a path from the loser back to the winner.

Many students try to detect cycles by checking if locked[loser][winner] already exists. That is wrong. A cycle can be longer than two edges (A→B→C→A). Always use DFS. Cs50 Tideman Solution

Your goal in lock_pairs :