โ† Amazon questions

Tree height from parent array

Filed under Amazon

Given an array `parent` of size `N` where `parent[i]` denotes the parent of the `i`-th node in a tree (and `-1` if it is the root), find the height of 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 Amazon questions

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