@@ -0,0 +1,1391 @@
+package interviewquestions.medium;%0A%0A/**%0A * Created by sherxon on 1/26/17.%0A */%0Apublic class SetMatrixZeroes %7B%0A    public static void main(String%5B%5D args) %7B%0A        int%5B%5D%5B%5D a = new int%5B%5D%5B%5D%7B%7B1, 2, 3, 4%7D, %7B0, 6, 7, 8%7D, %7B9, 8, 7, 6%7D%7D;%0A        setZeroes(a);%0A        for (int i = 0; i %3C a.length; i++) %7B%0A            for (int j = 0; j %3C a%5Bi%5D.length; j++) %7B%0A                System.out.print(a%5Bi%5D%5Bj%5D + %22 %22);%0A            %7D%0A            System.out.println();%0A        %7D%0A    %7D%0A%0A    static void setZeroes(int%5B%5D%5B%5D a) %7B%0A%0A        boolean first = a%5B0%5D%5B0%5D == 0;%0A%0A        for (int i = 0; i %3C a.length; i++) %7B%0A            for (int j = 0; j %3C a%5Bi%5D.length; j++) %7B%0A                if (a%5Bi%5D%5Bj%5D == 0) %7B%0A                    a%5Bi%5D%5B0%5D = 0;%0A                    a%5B0%5D%5Bj%5D = 0;%0A                %7D%0A            %7D%0A        %7D%0A        for (int i = 1; i %3C a.length; i++) %7B%0A            if (a%5Bi%5D%5B0%5D == 0)%0A                for (int j = 0; j %3C a%5Bi%5D.length; j++)%0A                    a%5Bi%5D%5Bj%5D = 0;%0A        %7D%0A        for (int i = 0; i %3C a%5B0%5D.length; i++) %7B%0A            if (a%5B0%5D%5Bi%5D == 0 && (i != 0 %7C%7C first))%0A                for (int j = 0; j %3C a.length; j++)%0A                    a%5Bj%5D%5Bi%5D = 0;%0A        %7D%0A        if (a%5B0%5D%5B0%5D == 0 && false) %7B%0A            for (int j = 0; j %3C a%5B0%5D.length; j++)%0A                a%5B0%5D%5Bj%5D = 0;%0A%0A            if (first)%0A                for (int j = 0; j %3C a.length; j++)%0A                    a%5Bj%5D%5B0%5D = 0;%0A%0A        %7D%0A%0A    %7D%0A%7D%0A

set matrix zeros