@@ -0,0 +1,684 @@
+/**%0A * Problem link: https://leetcode.com/problems/spiral-matrix-ii/%0A */%0A%0Apublic class Solution %7B%0A    int%5B%5D dx = %7B0, 1, 0, -1%7D;%0A    int%5B%5D dy = %7B1, 0, -1, 0%7D;%0A    %0A    public int%5B%5D%5B%5D generateMatrix(int n) %7B%0A        int%5B%5D%5B%5D mat = new int%5Bn%5D%5Bn%5D;%0A        int dir = 0;%0A        for(int x=0,y=0,i=1; i%3C=n*n; i++) %7B%0A            mat%5Bx%5D%5By%5D = i;%0A            int xx = x + dx%5Bdir%5D;%0A            int yy = y + dy%5Bdir%5D;%0A            if(xx %3C 0 %7C%7C xx %3E= n %7C%7C yy %3C 0 %7C%7C yy %3E= n %7C%7C mat%5Bxx%5D%5Byy%5D %3E 0) %7B%0A                dir = (dir + 1) %25 dx.length;%0A                xx = x + dx%5Bdir%5D;%0A                yy = y + dy%5Bdir%5D;%0A            %7D%0A            x = xx;%0A            y = yy;%0A        %7D%0A        return mat;%0A    %7D%0A%7D%0A

Create Spiral_Matrix_II.java