Hotel Visit,testcase fail

Cannot find the error in my code


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.

Oh Okay that’s great.
@Daniyal-Farooque-446199309332205 Please mark your doubt as resolved now.