Java || Best Solution ✅|| Beats 100% ✅
Approach\n- First, Reverse Every Row.\n- Then, Change the Value of the Elements\n- From 1 to 0 and 0 to 1.\n# Complexity\n- Time complexity: O(n^2)\n Add your t
# Approach\n- First, Reverse Every Row.\n- Then, Change the Value of the Elements\n- From 1 to 0 and 0 to 1.\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```\nclass Solution {\n    public int[][] flipAndInvertImage(int[][] image) {\n        for (int i = 0; i < image.length; i++) {\n            int a = 0, r = image[0].length - 1;\n            while (a <= r) {\n                int temp = image[i][a];\n                image[i][a] = image[i][r];\n                image[i][r] = temp;\n                a++;\n                r--;\n            }\n        }\n        for (int i = 0; i < image.length; i++) {\n            for (int j = 0; j < image[0].length; j++) {\n                if (image[i][j] == 0) {\n                    image[i][j] = 1;\n                } else {\n                    image[i][j] = 0;\n                }\n            }\n        }\n        return image;\n    }\n}\n```\n![please-upvote-and.jpg](https://assets.leetcode.com/users/images/e78315ef-8a9d-492b-9908-e3917f23eb31_1674946036.087042.jpeg)
['Java']