Given the roots of two complete binary trees T1 and T2 that have identical structure and the same number of nodes, replace each value in T2 with the sum of all node values in the corresponding subtree of T1 (including the matching root of that subtree). Implement:
(
-
a function that performs this transformation in O(n) time and O(h) extra space, where n is the number of nodes and h is tree height;
(
-
helpers to build a complete binary tree from a level-order array (use null for missing children) and to serialize a tree back to an array for testing. State assumptions and handle edge cases like empty trees, negative values, and integer overflow.