public static List<Integer> spiralOrder(int[][] matrix) {//AC
        if (matrix == null) return null;

        //corner case 2
        List<Integer> result = new ArrayList<Integer>();
        int row = matrix.length;
        if (row == 0) return result;

        int col = matrix[0].length;
        if (col == 0) return result;

        //regular
        int start_row = 0, end_row = row-1, start_col = 0, end_col = col-1;

        while (start_row <= end_row && start_col <= end_col) {
            subSpiral(result, matrix, start_row, end_row, start_col, end_col);
            start_row++;
            end_row--;
            start_col++;
            end_col--;
        }
        return result;
    }