I tested my code on my own machine and it works fine. However, after submitting my code to leetcode, the result always says Runtime Error without any details. I don't know why this happens.
I have experienced similar problems; I was using indices that went outside the bounds of the matrix. Maybe this will help you in revising your code, and eliminate the errors.
Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.