🔥🚀Beginner 🧠friendly🥰   | |    ✅Green Beats🙌🧠  | |  JAVA
Intuition\n- The horizontal flip is performed by reversing the order of elements in each row.\n- Inversion is achieved by changing 0s to 1s and 1s to 0s.\n- The
# Intuition\n- The horizontal flip is performed by reversing the order of elements in each row.\n- Inversion is achieved by changing 0s to 1s and 1s to 0s.\n- The combination of these two operations creates the desired result.\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n### 1. Horizontal Flip:\n\nFor each row in the image, reverse the order of its elements. This effectively flips the image horizontally.\n### 2. Invert:\n\nIterate through the flipped image and replace each 0 with 1 and each 1 with 0. This step achieves the inversion.\n### 3. Return Result:\n\nReturn the resulting image after both horizontal flipping and inversion.\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity: **O(N*M)**\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: **ON*M)**\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\n    public int[][] flipAndInvertImage(int[][] image) {\n        int [][] rev = new int[image[0].length][image.length];\n        for(int i=0; i<image.length; i++){\n            int k=0;\n            for(int j=image[i].length-1; j>=0; j--){\n                rev[i][k++] = image[i][j];\n            }\n        }\n        for(int i=0; i<rev.length; i++){\n            for(int j=0; j<rev[i].length; j++){\n                if(rev[i][j]==1) rev[i][j]=0;\n                else if(rev[i][j]==0) rev[i][j]=1;\n            }\n        }\n        return rev;\n    }\n}\n```\n![WhatsApp Image 2023-12-03 at 12.33.52.jpeg](https://assets.leetcode.com/users/images/6ff7963e-c65c-4056-aee9-ace044237626_1701756136.3264186.jpeg)\n
['Java']