@@ -0,0 +1,1806 @@
+// Solution 1%0A// O(m+n) space%0Apublic class Solution %7B%0A    public void setZeroes(int%5B%5D%5B%5D matrix) %7B%0A        if(matrix.length %3C 1)%0A            return;%0A        %0A        boolean%5B%5D isRowZero = new boolean%5Bmatrix.length%5D;%0A        boolean%5B%5D isColZero = new boolean%5Bmatrix%5B0%5D.length%5D;%0A        %0A        for(int i = 0; i %3C matrix.length; ++i) %7B%0A            for(int j = 0; j %3C matrix%5Bi%5D.length; ++j) %7B%0A                if(matrix%5Bi%5D%5Bj%5D == 0) %7B%0A                    isRowZero%5Bi%5D = true;%0A                    isColZero%5Bj%5D = true;%0A                %7D%0A            %7D%0A        %7D%0A        %0A        for(int i = 0; i %3C matrix.length; ++i) %7B%0A            for(int j = 0; j %3C matrix%5Bi%5D.length; ++j) %7B%0A                if(isRowZero%5Bi%5D %7C%7C isColZero%5Bj%5D)%0A                    matrix%5Bi%5D%5Bj%5D = 0;%0A            %7D%0A        %7D%0A    %7D%0A%7D%0A%0A// Solution 2:%0A// O(1) space%0Apublic class Solution %7B%0A    public void setZeroes(int%5B%5D%5B%5D matrix) %7B%0A        if(matrix.length %3C 1)%0A            return;%0A        %0A        // Because the state of row0 and the state of column0 would occupy the same cell, I let it be the state of row0, and use another variable %22col0%22 for column0%0A        int col0 = 1;%0A        for(int i = 0; i %3C matrix.length; ++i) %7B%0A            if(matrix%5Bi%5D%5B0%5D == 0)%0A                col0 = 0;%0A            for(int j = 1; j %3C matrix%5Bi%5D.length; ++j) %7B%0A                if(matrix%5Bi%5D%5Bj%5D == 0)%0A                    matrix%5Bi%5D%5B0%5D = matrix%5B0%5D%5Bj%5D = 0;%0A            %7D%0A        %7D%0A        %0A        // use bottom-up method can avoid the first row was manipulated by others%0A        for(int i = matrix.length - 1; i %3E= 0; --i) %7B%0A            for(int j = matrix%5Bi%5D.length - 1; j %3E= 1; --j) %7B%0A                if(matrix%5Bi%5D%5B0%5D == 0 %7C%7C matrix%5B0%5D%5Bj%5D == 0)%0A                    matrix%5Bi%5D%5Bj%5D = 0;%0A            %7D%0A            if(col0 == 0)%0A                matrix%5Bi%5D%5B0%5D = 0;%0A        %7D%0A    %7D%0A%7D%0A

Create SetMatrixZeroes.java