← All problemsSign in

1123. Lowest Common Ancestor of Deepest Leaves

LeetCodeHash TableTreeDepth-First SearchBreadth-First SearchBinary TreeOpen on judge ↗

Given the root of a binary tree, return the lowest common ancestor of its deepest leaves. Recall that: - The node of a binary tree is a leaf if and only if it has no children - The depth of the root of the tree is 0. if the depth of a node is d, the depth of each of its children is d + 1. - The lowest common ancestor of a set S of nodes, is the node A with the largest depth such that every nod

HINT LADDERno hints yet
L1 Observation
L2 Technique
L3 Approach
L4 Pseudo-code
🔒
L5 Full solution
L5 unlocks only if you insist twice
solution.cppC++17

CodeSearch Tutor

Hints, not spoilers — it won’t hand over the full solution unless you insist.

voice by Sarvam AI

Sign in to chat with the tutor and save your progress.

Sign in to start