Runtime error. Any suggestions?

I am getting correct for 2 test cases, but run time error for one. Any corner cases?

@BloodyOssan hey sayan bose use staircase search to implement this question for staircase search algorithm watch the video in your course content.

Yeah i did watch the lecture.
The problem seemed to be with the size declaration.
After tweaking for a bit, I declared the array size as n+1 and m+1.
it worked… lol
any idea why??