I followed the same approach of prateek bhaiya. I am just confused is binary tree in preorder format is here something different . Whether I should change my input lines of tree.
Is_balanced failed 3rd test case
i have modified you code you can see
you have done two mistakes
- height is max(left.height,right.height)+1;
- else balanced =false;
if you like hit like button
1 Like