Problem Statement
Partial Sum (or difference array technique) on Tree Problem Description You are given a tree with N nodes rooted at node 1. Each node has an initial value (given an values array). You must process Q queries, which can be one of two types: Type 1 (1 x y): Add the value y to all nodes in the subtree rooted at node x . Type 2 (2 x y): Add the value y to all nodes except for the nodes in the subtree rooted at node x . After all Q queries are finished, you must return the final values of all N nodes.