光阴似箭催人老,日月如移越少年。
After a cursory glance, j and k both start from 0, so [j-1][k] and [j][k-1] will fail
[j-1][k]
[j][k-1]
Try using a queue, breadth-first traversal, there are obviously some problems with using a for loop, for example, if you take m=1, you don’t look at the code carefully...
After a cursory glance, j and k both start from 0, so
[j-1][k]
and[j][k-1]
will failTry using a queue, breadth-first traversal, there are obviously some problems with using a for loop, for example, if you take m=1, you don’t look at the code carefully...