1506. Find Root of N-Ary Tree

Problem

Given all nodes of an N-ary tree in a list, find and return the root node.

You are given all the nodes of an N-ary tree in an array nodes. Each node has a val and a list of children. Find and return the root node of the tree.

The root is the only node that is not a child of any other node.

Examples
Input: [[1,[3,2,4]],[3,[5]],[2,[]],[4,[]],[5,[]]]
Output: 1
Hints
Related Problems

1506. Find Root of N-Ary Tree

Given all nodes of an N-ary tree in a list, find and return the root node.