I am geeting an error in scanner class. i don't getting it


this is my code.
it doesn’t taking character as input . and showing some scanner class error. i used this method before its work fine ther. i dont geeting why it doesn;t working here.

Hi @Adi_choudhary,
See the input is in single line string so for example for input XXX0 when you do char at (0) you take first X and discard the rest of string so here i have corrected your code . Just put the XXX0 in a string first and then take individual characters.check this code

it showing me wrong answer in 4 out of 5 cases. is there something wrong with my logic??

Yes obviously when 4 out of 5 test case are wrong your logic is wrong … You are not considering the case when the rat can move left and up.

thanx . i solved it now