Java Solution || Beats 100% Complexity || Easy to understand functions
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n1) Find reverse of each row. For a 2D array every element at each index i
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n1) Find **reverse of each row**. For a 2D array every element at each index is another array. So pass the rows to the reverse function. \n\n2) Reverse function swaps the first and last element of array, and then second and second last and so on... Thus in place sorting, no new array is made.\n\n3) After horizontal flipping, now **invert**. Since it contains only binary numbers therefore complement using **Bitwise XOR**.\n    1 ^ 1 = 0\n    0 ^ 1 = 1\nTherefore to generalise , **a ^ 1 =  ~ a**\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\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            reverse(image[i]);\n\n        for(int i=0; i<image.length;i++)\n        {\n            for(int j=0;j<image[i].length;j++)\n                image[i][j] = image[i][j] ^ 1; //gives complement a ^ 1 = complement\n        }\n        return image;\n    }\n\n\n    void reverse(int[] arr) {\n        int start = 0;\n        int end = arr.length-1;\n\n        while (start < end) {\n            swap(arr, start, end);\n            start++;\n            end--;\n        }\n    }\n    void swap(int[] arr, int index1, int index2) {\n        int temp = arr[index1];\n        arr[index1] = arr[index2];\n        arr[index2] = temp;\n    }\n}\n```
['Array', 'Bit Manipulation', 'Java']