Skip to content
StackDecode
TreesExplained

Top View

The first node seen at each horizontal distance from above.

Time

O(n)

Extra space

O(n)

Use it for

What you see looking down on the tree.

An animated walkthrough for this algorithm isn’t built yet. The summary above explains the idea; see the related animated algorithms below to practise the same technique.