Testcase 5 is showing run error. Why? Is there any other better way of constructing the tree and finding top view?
Trees - Tree top view
@yashomar95,
Actually your code is correct. The problem is in the sample test case. There is an extra space in the input which throws erros in bufferedreader. You can remove the stray space from the string array. I will notify the support to rectify this as well