[Google(3)]->832. Flipping an Image [O(N) solution][C++].
Approach\nAll the approach is well explained in the question. During swapping for reversal of array used xor with 1 to flip the bit i.e inverting because 1^1=0 
# Approach\nAll the approach is well explained in the question. During swapping for reversal of array used xor with 1 to flip the bit i.e inverting because 1^1=0 , 0^1=1 for simplicity of code.By combining both steps it decreases time complexity from O(N^2) to O(N).\n\n# Complexity\n- Time complexity:\nO(N)\nIt seems O(N^2) but the loops are running for each row and half column so Actual Time comlexity is O(rows*columns) which is equal to O(N) as N=no of elements=rows*columns(as per this question).\n\n- Space complexity:\nO(1)\n\n# Code\n```\nclass Solution {\npublic:\n        vector<vector<int>> flipAndInvertImage(vector<vector<int>>& image) {\n        int n=image.size();\n        for(int i=0;i<n;i++)\n        {\n            for(int j=0;j<(n+1)/2;j++)\n            {\n                int temp=image[i][j]^1;\n                image[i][j]=image[i][n-1-j]^1;\n                image[i][n-1-j]=temp;\n            }\n        }\n        return image;\n    }\n};\n```
['Matrix', 'C++']