class Solution {
public:
    /**
     * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可
     *
     * 
     * @param matrix int整型vector<vector<>> 
     * @return int整型vector
     */
    vector<int> spiralTravelCounterClockwise(vector<vector<int> >& matrix) {
        // write code here
        int row = matrix.size(), col = matrix[0].size();
        int left = 0, right = col-1, top = 0, bottom = row-1;
        int n = row * col;
        int total = 0;
        vector<int> ans;
        while (total < n) {
            for (int i = top; i <= bottom; i++) {
                ans.push_back(matrix[i][left]);
                total++;
            }
            if (total == n) break;
            left++;
            for (int i = left; i <= right; i++) {
                ans.push_back(matrix[bottom][i]);
                total++;
            }
            bottom--;
            if (total == n) break;
            for (int i = bottom; i >= top; i--) {
                ans.push_back(matrix[i][right]);
                total++;
            }
            right--;
            if (total == n) break;
            for (int i = right; i >= left; i--) {
                ans.push_back(matrix[top][i]);
                total++;
            }
            top++;
        }
        return ans;
    }
};