I think one of the tests is wrong.


  • 2
    F

    {1,2,2,3,3,3,3,4,4,4,4,4,4,#,#,5,5} looks like, if i am right:

             1
          /     \ 
         2       2
        / \      / \
       3   3    3   3
       /\  /\  /\   
      4 4 4 4 4 4 
     /\
    5 5
    

    test case expects code to return true. this tree is patently not balanced.


  • 6
    S

    For this problem, a height-balanced binary tree is defined as a binary tree in which the depth of the two subtrees of every node never differ by more than 1.

    The left subtree depth of node 1 is 4, the right substree is 3. Not more than 1.

    The two depth of left node 2 is 3 and 2, not more than 1.
    The two depth of right node 2 is 2 and 1, not more than 1.


Log in to reply
 

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