Cannot find the error in my code
Hotel Visit,testcase fail
Here is a much simpler and easy to understand implementation of this question. Tell me if you are able to understand it.
Thanks! yeah i know that can be done too.The error was because of integer overflow .Found it from your code.