What should be the output of this input?


  • 1
    Q

    Hi, I am wondering what should be the output of this tree input ?

    [1,2,3,4,5,null,null,null,null,6,7]

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

    should it be [4,5,2,6,7,3,1] (the expected output) or [4,6,2,7,5,3,1] (where you also flip upside down on the [5, 6,7] subtree


  • 1
    M

    node 5 does not satisfy this condition: All right nodes are either leaf nodes with a sibling (a left node that shares the same parent node) or empty.


  • 0
    V

    As above post said, the premise of your question is flawed. It is an invalid input.


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.