Question statement is wrong. Right que is in comment body


Question statement is incomplete!

Basically we have to find if its possible to reach rightmost bottom cell from 0,0. If yes return length of longest path else return -1.

P.S. all paths from 0,0 to n-1,m-1 will have same length as we can travel only down or right so you can just return n+m-1 as well. Either approach will work.

Pretty easy!