Skip to content

Latest commit

 

History

History
43 lines (34 loc) · 2.07 KB

File metadata and controls

43 lines (34 loc) · 2.07 KB

< Previous                  Next >

Related Topics

[Tree] [Depth-First Search] [Binary Tree]

Similar Questions

  1. Lowest Common Ancestor of a Binary Search Tree (Easy)
  2. Lowest Common Ancestor of a Binary Tree (Medium)
  3. Lowest Common Ancestor of Deepest Leaves (Medium)
  4. Lowest Common Ancestor of a Binary Tree II (Medium)
  5. Lowest Common Ancestor of a Binary Tree III (Medium)
  6. Lowest Common Ancestor of a Binary Tree IV (Medium)

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.