Replace each node of a binary tree with the sum of its cousins' values.
Unlock detailed company stats for this questionUpgrade
Given a binary tree, create a new tree where each node contains the sum of the values of all its cousins.
One approach: first pass to store the sum of each level; second pass computing each node's sibling sum (children of the same parent); the new node value is level_sum - sibling_sum.
Community answers
No answers contributed by the community yet.


