Search
⌘K
Get Premium
Leetcode 1644. Lowest Common Ancestor of a Binary Tree II
Given a binary tree and two target nodes p and q, return their lowest common ancestor if and only if both targets exist in the tree, otherwise return null. The main challenge is to compute the LCA while simultaneously verifying the presence of p and q during a single traversal (e.g., post-order DFS).
Asked at:
Amazon
Meta
Question Timeline
See when this question was last asked and where, including any notes left by other candidates.
All Regions
Early November, 2025
Meta
Manager
Given Two Nodes of the tree, find the lowest common ancestor for the two nodes
Mid December, 2024
Amazon
Mid-level
Find the lowest common ancestor of a binary tree
Comments
Hello Interview Premium
Your account is free and you can post anonymously if you choose.