DFS method to traverse through edges , calculating subtree sum at each node and updating the difference between subtrees
static void dfs ( int u , int parent , int totalSum , ArrayList < Integer > [ ] edge , int subtree [ ] ) { int sum = subtree [ u ] ;