SIMPLE XOR EXPLANATION USING TWO-POINTER
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:o(n^2)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:o(1)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\n/*\na = 5 (in binary: 101)\nb = 3 (in binary: 011)\nWe can swap a and b using XOR without needing a temporary variable:\n1. a = a ^ b \u2192 101 ^ 011 = 110 (so now a = 6)\n2. b = a ^ b \u2192 110 ^ 011 = 101 (so now b = 5, which was the original value of a)\n3. a = a ^ b \u2192 110 ^ 101 = 011 (so now a = 3, which was the original value of b)\nAfter these operations, a becomes 3 and b becomes 5, effectively swapping their values.\n*/\nclass Solution {\npublic:\n    vector<vector<int>> flipAndInvertImage(vector<vector<int>>& image) {\n        int n = image.size();\n        for(auto&row : image){\n            int i = 0;\n            int  j = n - 1;\n            while (i <= j){\n                if(i == j){\n                    row[i] ^= 1; // Invert the middle element when i == j in odd length rows\n                }else{\n                    // Swap using XOR and invert\n                    row[i] ^= row[j];\n                    row[j] ^= row[i];\n                    row[i] ^= row[j];\n                    row[i] ^= 1;\n                    row[j] ^= 1;\n\n                }\n               i++;\n                j--;\n            }\n        }\n        return image;\n    }\n};\n```
['C++']