Java solution with 0ms runtime | Beats 100% | TC = O(n*n)
If you found it easy to understand, Please do upvote :)\nThankyou!!\n-------------------------------------------------------------------------------------------
**If you found it easy to understand, Please do upvote :)\nThankyou!!**\n**--------------------------------------------------------------------------------------------------**\n![Today Leetcode Pic.JPG](https://assets.leetcode.com/users/images/c219a0c5-a102-4ce7-9d88-f5a3a783acdc_1670570648.5850391.jpeg)\n**--------------------------------------------------------------------------------------------------**\n# Complexity\n- Time complexity: O(n*n)\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{\n    public int[][] flipAndInvertImage(int[][] image) \n    {\n        //Flipping\n        for(int i=0; i<image.length; i++)\n        {            \n            for(int left=0, right=image[i].length-1; left<=right; left++, right--)\n            {\n                //Two-pointer approach\n                int temp = image[i][left];\n                image[i][left] = image[i][right];\n                image[i][right] = temp;\n            }\n        }\n\n        //Inverting\n        for(int i=0; i<image.length; i++)\n        {\n            for(int j=0; j<image[i].length; j++)\n            {\n                image[i][j] = image[i][j]==0 ? 1 : 0;\n            }\n        }\n        return image;\n    }\n}\n```
['Matrix', 'Java']