← Amazon questions

Find diameter of BST in O(n)

Filed under Amazon

Given a list of integers, insert them into a Binary Search Tree (BST) and calculate the diameter of the resulting tree in O(n) time. The diameter is the length of the longest path between any two…

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.