Algorithm · LinkedIn · Medium
You are given the roots of two binary trees, root1 and root2. Combine them into a single new binary tree and return the root of that combined tree. The combination works position by position. Where both trees have a node in the same position, the resulting node holds the sum of the two values. Where exactly one of the trees has a node in a position, that node is carried over as-is, together with everything beneath it. Where neither tree has a node, the resulting tree has no…