Why this test case is symmetric tree


  • 0
    O

    I got failed because of the input case:

    Input: [3,4,4,5,null,null,5,6,null,null,6]
    Output: false
    Expected: true

    but in my understanding,
    this test case should be

                 3
                 /\ 
         4              4
         /\            /\
     5      #     #     5
     /\      /\     /\     /\
    6 #      # 6    # #    # #
    

    and this should not be a symmetric tree.

    Furthermore, the format is not match with what it explained in
    'how binary tree is serialized on OJ.'

    Am I wrong?

    Or dose ''null" represents consecutive '#', which makes the input be
    [3,4,4,5,#,#,5,6,#,#,#,#,#,#,6]?

    Thanks!


  • 1
    I

    The input [3,4,4,5,null,null,5,6,null,null,6] represents

                               3
                         /          \
                      4               4
                    /   \             /  \
                  5      #          #     5
                 /  \                    /   \
               6    #                  #      6
    

    When the node is #, don't assign subtrees for it.

    Sorry for my poor English, hope to make it clear.


  • 0
    O

    Thanks for answering! I don't know why I think there would be a node below a null node 6 days ago... XD Thanks anyway!


Log in to reply
 

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