One pass in place JAVA Solution
\nclass Solution {\n    public int[][] flipAndInvertImage(int[][] A) {\n        int n = A.length;\n        for(int j = 0; j < n / 2 + n % 2; j++){\n            
```\nclass Solution {\n    public int[][] flipAndInvertImage(int[][] A) {\n        int n = A.length;\n        for(int j = 0; j < n / 2 + n % 2; j++){\n            for(int i = 0; i < n; i++) {\n                int tmp = A[i][j];\n                A[i][j] = A[i][n - 1 - j] ^ 1;\n                A[i][n - 1 - j] = tmp ^ 1;\n            }\n        }\n        return A;\n    }\n}\n```
[]