Is balanced (binary tree

https://hack.codingblocks.com/contests/c/537/475

my solution
https://ide.codingblocks.com/s/45608

My code is failing on test case 3 and it is not time limit error.
What is the problem.
thanks

c is a global bool type variable I am using.

I am facing I guess similar problem for structurally identical BT. I am getting 2 wrong answers.
problem: https://hack.codingblocks.com/contests/c/537/474
solution
https://ide.codingblocks.com/s/45612

Hey Prabal, your code is giving true for every test case as your c variable is not updating.

1 Like

hello,

https://ide.codingblocks.com/s/45693
I have fixed the problem ,now only test case 3 is not passing (for structurally identical bt)

Hey Prabal, your code is not satisfying some of the test cases. Check for this test case

input :
50 true 12 true 18 false false false false

correct output should be false.

Yes ,Sir I have fixed the problem and I am getting all test cases passes for IS BALANCED BT problem.

https://ide.codingblocks.com/s/45693
The above link is for STRUCTURALLY IDENTICAL BT problem. Here my test case 3 is not passing.

Problem link:
https://hack.codingblocks.com/contests/c/537/474

Hey Prabal, in this problem you just have to check if the binary trees are structurally identical or not. So, it doesn’t matter if the data of nodes of the trees are equal or not, what we are concerned about is only the structure of both the trees.
For eg.
10 true 21 true 40 false false true 50 false false true 30 true 60 false false true 73 false false
10 true 20 true 41 false false true 51 false false true 30 true 60 false false true 73 false false
output for this case should be true. As data of nodes of these two trees are not equal but their structure is same.

1 Like