โ† Amazon questions

Print leaves corresponding to tree diameter

Filed under Amazon

Given a binary tree, find its diameter (the length of the longest path between any two nodes in a tree) and print or return the leaf nodes that correspond to the endpoints of that diameter path.

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

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