• + 1 comment

    That describes a different problem (or different constraints). The other solutions posted here and the editorial can help clarify what is wanted.

    https://www.hackerrank.com/challenges/tree-top-view/editorial