LeetCode
01 Matrix
Click
here
for an explanation.