• + 0 comments

    If we take the tree as in Faland's comment.

          1
         / \
        2   3
       / \
      4   5
           \
            6
             \
              7
    

    The answer for which the compiler successfully runs the test is 4-2-1-3-7

    and for

          1
         / \
        2   3
       / \
      4   5
         / 
        6
       /
      7
     /
    8 
    

    output is 8-4-2-1-3 which compiler accepts.

    You may refer geeks for geeks for the top view.