The reference code is broken.


  • -1
    O

    Try this test case:

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

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

    Is this tree balanced? Per the reference code/test, yes, it is.


  • 1
    O

    For the people negging this thread: Why don't you drop a line and explain your point?


  • 1
    O

    depth of the two subtrees of every node never differ by more than 1

    I think the wording of the question is bad which is making this confusing as the definition of a tree depth is:

    The depth of a node is the number of edges from the node to the tree's root node.

    But the question actually wants height-balanced, so you could suggest an edit to the question.

    (For the example you provided, it's definitely height balanced.)


Log in to reply
 

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