A possible implementation of this algorithm using O(m+n) space complexity but it's a bit easy to understand.
https://www.youtube.com/watch?v=hhhDrprn8MU
https://github.com/compilewithpriya/Leetcode-cpp-practice/blob/master/Set-Matrix-zeroes.cpp