← Microsoft questions

Distance Between Two Nodes in Binary Tree

Filed under Microsoft · Also reported at OneDirect

Given a binary tree and two target nodes, find the shortest distance (number of edges) between them. The distance is the path length between the two nodes in the tree.

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 Microsoft questions

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