← Goldman Sachs questions
CodingReported in a candidate post, Jun 2026

Lowest common ancestor and k-distance nodes variation

Filed under Goldman Sachs

Given a binary tree and two nodes a and b, find their lowest common ancestor (LCA). Then, as a variation, given a target node and an integer k, return all nodes at distance k from the target, where…

You've read your 3 free write-ups

Sign up free to keep reading. Your account opens the first 10 questions of every company.

Related Goldman Sachs questions

Collected from public candidate posts and coding forums. Updated Nov 2026.