← Back to companies
[ OK ] Loaded —
[ INFO ]
$ cd
$ ls -lt
01
02
03
04
05
$ ls -lt
01
02
03
04
05
user@intervues:~/$
You are given a tree with n nodes (0-indexed) that models a flow network. Each node i has a non-negative integer flow value flow[i]. The tree is represented by a parent array parent of length n where parent[i] is the parent of node i for i > 0, and parent[0] = -1 (the root). Exactly one edge can be removed to partition the tree into two subtrees. Let S1 and S2 be the sums of the flow values in the two resulting components. Return the minimum possible absolute difference |S1 - S2| that can be achieved by cutting any single edge.