please check what is the problem in the code.
Run error coming
Hello @Akshita99,
Your code is failing for the test cases like:
-
1
5
4 3 2 5 6
1 3
Expected Output:
2 3 -
1
5
4 3 2 5 6
5 7
Expected Output:
5 6 -
1
5
4 2 7 5 6
3 5
Expected Output:
4 5
All the examples are similar.
Correct it.
Let me know if you still face any issue.
sir in the last example you gave why will we print 6 also. it is a sibling of 5
sir the example given in question is not quite clear. Can you give one where the tree is perfect binary
Hello @Akshita99,
-
Yes, you are correct, it should only be 4 5
-
What is your mistake is that you are not considering the case when the number given in the range is not present in the tree.
So, basically you have to just include some checks in your code.
You can refer to the following code for your mistake:
https://ide.codingblocks.com/s/231362
If you still don’t find it, let me know.
I’ll correct it for you.