Ad
  • Custom User Avatar

    Hi; I just solved this and I must agree that it was quite frustrating to debug as the output/display of wrong results is not very clear.

    Also, you are clearly on the right track - your recursive logic is correct but your base case is where things are going wrong I think.

    Using your code, you are failing 3 of the fixed tests - however, none of these correspond to the trees that you have drawn above though (so I'm not sure how you managed to obtain that drawing).

    For example, of the 3 test cases where your code is failing, the first one actually is testing the following pair of trees a,b:

    # tree a              tree b
        3                    3
      /  \                  / \
     1    1                1   2
    

    and the expected answer is False for this input pair.

    Hopefully that helps you debug a bit better (I can't share with you more of the test cases because otherwise people could just hardcode the correct answer, as there are no random tests).