Loading problem…
Nodes are labeled 0 through n - 1. The two arrays describe each node's left and right child; -1 means that child is absent. Return whether these links form exactly one valid binary tree containing all n nodes.
A valid tree has exactly one root, every other node has exactly one parent, and all nodes are reachable from the root without a cycle. Labels are identities, not values or an ordering rule: the root need not be node 0.
Example 1:
Example 2:
Example 3: