You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- Space: O(1) (Assuming creating the result is not extra space)
7
+
- N = Number of elements in both trees
8
+
9
+
By traversing both trees together, the solution is much simpler.
10
+
Use one of the trees as your primary merge tree during the recursion and create new nodes when the primary doesn't have one and the secondary tree does.
11
+
With recursion, you need to create the new nodes when you are the parent before you perform a function call into that node.
12
+
You cannot create the new node if the node doesn't exist after the call.
0 commit comments