@@ -0,0 +1,1737 @@
+import java.util.ArrayList;%0Aimport java.util.List;%0A%0Apublic class LeetCode0054 %7B%0A    public List%3CInteger%3E spiralOrder(int%5B%5D%5B%5D matrix)%0A    %7B%0A        List%3CInteger%3E result = new ArrayList%3CInteger%3E();%0A        if (matrix == null %7C%7C matrix.length == 0 %7C%7C matrix%5B0%5D.length == 0) %7B%0A            return result;%0A        %7D%0A%0A        int firstRow = 0, lastRow = matrix.length, firstCol = 0, lastCol = matrix%5B0%5D.length;%0A%0A        while (firstRow %3C lastRow && firstCol %3C lastCol) %7B%0A            int i = firstRow, j = firstCol;%0A            if (j == lastCol) %7B%0A                break;%0A            %7D%0A            for (; j %3C lastCol; j++) %7B%0A                result.add(matrix%5Bi%5D%5Bj%5D);%0A            %7D%0A            lastCol--;%0A            j--;%0A            i++;%0A            if (i == lastRow) %7B%0A                break;%0A            %7D%0A            for (; i %3C lastRow; i++) %7B%0A                result.add(matrix%5Bi%5D%5Bj%5D);%0A            %7D%0A            lastRow--;%0A            i--;%0A            j--;%0A            if (j %3C firstCol) %7B%0A                break;%0A            %7D%0A            for (; j %3E= firstCol; j--) %7B%0A                result.add(matrix%5Bi%5D%5Bj%5D);%0A            %7D%0A            firstCol++;%0A            j++;%0A            i--;%0A            if (i %3C= firstRow) %7B%0A                break;%0A            %7D%0A            for (; i %3E firstRow; i--) %7B%0A                result.add(matrix%5Bi%5D%5Bj%5D);%0A            %7D%0A            firstRow++;%0A        %7D%0A%0A        return result;%0A    %7D%0A%0A    public static void main(String%5B%5D args)%0A    %7B%0A        LeetCode0054 leetcode = new LeetCode0054();%0A%0A        int%5B%5D%5B%5D matrix = %7B %7B 7 %7D, %7B 9 %7D, %7B 6 %7D %7D;%0A        List%3CInteger%3E result = leetcode.spiralOrder(matrix);%0A        for (int i = 0; i %3C result.size(); i++) %7B%0A            System.out.print(result.get(i) + %22 %22);%0A        %7D%0A    %7D%0A%7D%0A

Add LeetCode0054.java