In this problem, a rooted tree is a directed graph such that, there is exactly one node (the root) for which all other nodes are descendants of this node, plus every node has exactly one parent, except for the root node which has no parents. The given input is a directed graph that started as a rooted tree with n nodes (with distinct values from 1 to n), with one additional directed edge added. Return an edge that can be removed so that the resulting graph is a rooted tree of n nodes.
Java
Redundant Connection II
In this problem, a rooted tree is a directed graph such that, there is exactly one node (the root) for which all other nodes are descendants of this node, plus every node has exactly one parent, except for the root node which has no parents. The given input is a directed graph that started as a rooted tree with n nodes (with distinct values from 1 to n), with one additional directed edge added. Return an edge that can be removed so that the resulting graph is a rooted tree of n nodes.
Example 1:
Input: [[1,2],[1,3],[2,3]]
Output: [2,3]
Input
arr =[[1,2],[1,3],[2,3]]
Starting with 3 edges. Looking for node with two parents.