public static void subSpiral (List<Integer> result, int[][] matrix, 
    		int start_row, int end_row, int start_col, int end_col) {//AC

        for (int j = start_col; j <= end_col; ++j) {
            result.add(matrix[start_row][j]);
        }

        for (int i = start_row+1; i <= end_row; ++i) {
            result.add(matrix[i][end_col]);
        }
        if (start_row != end_row) {
            for (int j = end_col-1; j >= start_col; --j) {
                result.add(matrix[end_row][j]);
            }
        }
        if (start_col != end_col) {
            for (int i = end_row-1; i > start_row; --i) {
                result.add(matrix[i][start_col]);
            }
        }
    }