← Amazon questions

Find the diameter of a binary tree and number of islands

Filed under Amazon

Given a binary tree, write production-level code to find its diameter (the length of the longest path between any two nodes). Additionally, write code to find the number of islands in a 2D grid using…

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.