[Java/C++/Python] Reverse and Toggle
Explanation:\n1. reverse every row.\n2. toggle every value.\n\nIn Java, I did both steps together:\nCompare the i th and n - i - 1 th in a row.\nThe "trick" is 
# **Explanation**:\n1. reverse every row.\n2. toggle every value.\n\nIn Java, I did both steps together:\nCompare the `i` th and `n - i - 1` th in a row.\nThe "trick" is that if the values are not the same,\nbut you swap and flip, nothing will change.\nSo if they are same, we toggle both, otherwise we do nothing.\n<br>\n\n# **Complexity**:\nTime `O(N^2)`\nSpace `O(N^2)` for output\n<br>\n\n**Java:**\n```java\n    public int[][] flipAndInvertImage(int[][] A) {\n        int n = A.length;\n        for (int[] row : A)\n            for (int i = 0; i * 2 < n; i++)\n                if (row[i] == row[n - i - 1])\n                    row[i] = row[n - i - 1] ^= 1;\n        return A;\n    }\n```\n**C++:**\nby @guybrush2323\n```cpp\n    static const vector<vector<int>>& flipAndInvertImage(vector<vector<int>>& A) {\n        for (auto& row : A) {\n            reverse(row.begin(), row.end());\n            for (auto& v : row) v ^= 1;\n        }\n        return A;\n    }\n```\n**1-line Python:**\n```python\n    def flipAndInvertImage(self, A):\n        return [[1 ^ i for i in reversed(row)] for row in A]\n```\n
[]