NeetCode #419LC-236MediumTrees
← Back to All Problems#419 · #236 · Lowest Common Ancestor of a Binary Tree(二叉树的最近公共祖先)
📌 Problem Statement & Constraints
Given a binary tree and two nodes
p and q, return their lowest common ancestor: the deepest node that has both as descendants (a node may be a descendant of itself). Constraints: the number of nodes is in [2, 10^5], all values are distinct, both nodes exist.🔒
Sign In to Unlock Full Solutions for All 973 Problems
Sign in to access step-by-step logic, benchmark Python3 code, complexity breakdown, and offline export!