@@ -0,0 +1,922 @@
+public class Solution %7B%0A    public int%5B%5D%5B%5D generateMatrix(int n) %7B%0A        int%5B%5D%5B%5D result = new int%5Bn%5D%5Bn%5D;%0A        %0A        int rowStart = 0, rowEnd = n;%0A        int colStart = 0, colEnd = n;%0A        int count = 0;%0A        %0A        while(rowStart %3C rowEnd && colStart %3C colEnd) %7B%0A            for(int j = colStart; j %3C colEnd; ++j) %7B%0A                result%5BrowStart%5D%5Bj%5D = ++count;%0A            %7D%0A            rowStart++;%0A            %0A            for(int i = rowStart; i %3C rowEnd; ++i) %7B%0A                result%5Bi%5D%5BcolEnd - 1%5D = ++count;%0A            %7D%0A            colEnd--;%0A            %0A            for(int j = colEnd - 1; j %3E= colStart; --j) %7B%0A                result%5BrowEnd - 1%5D%5Bj%5D = ++count;%0A            %7D%0A            rowEnd--;%0A            %0A            for(int i = rowEnd - 1; i %3E= rowStart; --i) %7B%0A                result%5Bi%5D%5BcolStart%5D = ++count;%0A            %7D%0A            colStart++;%0A        %7D%0A        return result;%0A    %7D%0A%7D%0A

Create SpiralMatrixII.java