Flipping an Image

Dec 23, 2019

第47天

今天的题目是Flipping an Image:

考试周,做一道Easy题。

vector<vector<int>> flipAndInvertImage(vector<vector<int>>& A) {
    int t;
    for(auto &v: A) {
        for(int i = 0, j = v.size() - 1;i <= j; i++, j--) {
            t = (v[j]==1) ? 0 : 1;
            v[j] = (v[i]==1) ? 0 : 1;
            v[i] = t;
        }
    }
    return A;
}
LeetCodeLeetCode

Maximum Length of Repeated Subarray & Edit Distance

Interval List Intersections

comments powered by Disqus