1676. Lowest Common Ancestor of a Binary Tree IV
Hash TableTreeDepth-First SearchBinary TreeBinary LiftingLowest Common Ancestor
Hints
Hint 1
Starting from the root, traverse the left and the right subtrees, checking if one of the nodes exist there.
Hint 2
If one of the subtrees doesn't contain any given node, the LCA can be the node returned from the other subtree
Hint 3
If both subtrees contain nodes, the LCA node is the current node.
Preparing judge…