Testcase number 3 not getting cleared

I am able to pass test cases 1, 2 and 4 but having problem with test case number 3. Also I have a doubt. Can there be a possibiity when the fisrt input is false. In that case there should not be any node present, right; i wrote another code considering this also but even this does not seen to work.

Code consifering first input is never “false” : https://ide.codingblocks.com/s/107298

Considering that first input might be “false” :

Hello @shubh17,

You have understood the question wrongly.
You are required to check if the trees are structurally identical or not.
Example1:
10 true 20 true 40 false false true 50 false false true 30 true 60 false false true 73 false false
10 true 20 true 40 false false true 50 false false true 30 true 60 false false true 73 false false
Example2:
10 true 20 true 40 false false true 50 false false true 30 true 60 false false true 73 false false
10 true 20 true 40 false false true 50 false false true 30 true 53 false false true 73 false false

Both are structurally identical but your code is printing false for second case.

Solution:
You need not to check if two nodes have same values.

Hope, this would help.
Give a like, if you are satisfied.

1 Like

Oh…I got the question wrong. It worked for me, just had to remove one line. Thank a lot.

Please, mark the doubt as resolved.
BTW, i wont mind a like.:joy:

1 Like