Your Dashboard
Interview Coaching
Learn
System Design
ML System Design
Code
Behavioral
Salary Negotiation
Interview Guides
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
Question Timeline
See when this question was last asked and where, including any notes left by other candidates.
All Regions
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.