Given an unordered list of pairs where each pair represents a parent-child relationship (not nessesary direct) in an N-ary tree. Reconstruct and return the original tree. You can assume that each node has a unique value.
Example 1:
Input: [[1, 2], [1, 3], [1, 4], [2, 4]]
Output:
1
/ \
2 3
/
4Example 2:
Input: [[1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [2, 4], [2, 5], [2, 7], [3, 6], [4, 7]]
Output:
1
/ \
2 3
/ \ \
4 5 6
/
7