Tree bottom view- Binary tree

Test case 2 is showing wrong answer

check for this
20 8 22 5 3 4 25 -1 -1 10 14 -1 -1 -1 -1 -1 -1 -1 -1
u will find ur error

Yes i know but i am unable to find the error in the code

ur coding is printing 22 instread of 14
i will gave u a hint
u have taken a horizontal distance
also take a level varible

if u find a d and increase level just replace the current value as d for 14 and 22 are same but level of 4 id greater than 22

hope this help :slight_smile:

1 Like