Balanced Drainage Split
Two Sigma interview questions · Medium · OA round · 6 tests
You are given a rooted tree representing a water-drainage network. Nodes are labeled
0 through n - 1, and node 0 is the root. Water enters the
system at every node and then flows upward toward the root.
The tree is described by:
parent[i]: the parent of nodei, withparent[0] = -1input[i]: the amount of water entering at nodei
Run your code with Ctrl+Enter to see results.