AI Interview Prep is optimized for larger screens
Please open this on a laptop or desktop (1024px and wider) to use the full editor, whiteboard, and AI coaching surface.
Understand the problem
Restate the problem precisely. Interviewers reward candidates who pause, define the contract, and name the guarantees before coding.
Given a binary tree, find the lowest common ancestor (LCA) of two given node values `p` and `q` in the tree. According to the definition: the lowest common ancestor is defined between two nodes p and q as the lowest node in T that has both p and q as descendants (where we allow a node to be a descendant of itself). Return the *value* of the LCA node (instead of the node itself, for unit-test parity).
Once you've drafted a response, click Submit for AI review and a senior engineer will critique your reasoning.