Redundant connection directed
Your task
A rooted tree with n nodes (labeled 1..n) had exactly one extra directed edge added. The result is a directed graph where each edge u to v means v's parent is u. Because of the added edge, the graph violates a tree in one of two ways: some node has two parents, or there is a directed cycle (or both). Given the edges in the order they were added, return the one edge that can be removed so the remaining graph is a rooted tree. If multiple answers, return the edge that occurs last in the input.
Examples
find_redundant_directed(edges: list[list[int]]) -> list[int]Example 1
Input
find_redundant_directed([[1, 2], [1, 3], [2, 3]])Output
[2, 3]