Rat in a maze run time error in code

Only one testcase passes and in all other there is a run time error…please help me in my code

@Mravinash,

https://ide.codingblocks.com/s/230815 corrected code.

There was a problem in your input format. I have corrected the error and commented on the lines I have edited for your reference.

Input n strings of length m. And then assign them to each row of your char array.

@Mravinash,
what problem are you facing?

System is giving the input in a form of string??

@Mravinash,
In java we don’t have a method to get char input.

next().charAt(0)

The .next() function returns the next word in the input as a string and charAt(0) function returns the first character in that string.

So what happens is we only get the first character of the input.

If there is a space after every input this method will work but if the input is a string of length greater than length 1, it will still return only the first char. Hence the error.

In the input format we need to take input in the form of a string and since there is no space after every character we will assign them afterwards.