Why wrong output?
I have edited your code… Instead of using a pair, I have used normal function… and now its working perfectly fine…Pls refer to it…
This solution is O(hn) . What was the problem in my code ?
Your code is not working correctly for following test case as :
50 true 12 true 18 false false false false
Expected output : false
Your output : true