Here is my code: https://ide.codingblocks.com/s/252865
Why my testcase2 is failng?
@navin_japes
your code is not even passing the sample test case.
it is because you have taken the wrong input, first it should be pre[] input then ino[] input.
@navin_japes
also make a check for the case when there are no nodes present for the given target node or if target node is not present then in that case you need to print 0.
Are you joking should I send a screenshot that it passed all the three testcase
By the way how to check if the target node is not present can you modify the code for that part only how to do that.
@navin_japes
why i should joke with you
i checked the above code link on the problem given in challenges section, there it is not passing any test case. (because in that code you haven’t cleared the vector).
for checking target node is present or not you can check after the return from find() function if it is NULL or not.
For checking if there is any node present or not at distance k then you can just if the size of vector for that test case is zero or not.
@navin_japes
this is your updated code. Have a look if any doubt then ask.
If this is clear now, then please mark this doubt as resolved.
@navin_japes
i have already shared the code.
In your code why you are breaking the loop in case not node is function? Its simple, just print “0” and proceed for further cases.
Yeah done Thank you it passed all the testcases
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.