Skip to content

Files

Latest commit

author
Shuo
Feb 16, 2022
ce6b544 · Feb 16, 2022

History

History

lowest-common-ancestor-of-a-binary-tree-iv

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
Feb 16, 2022

< 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.