Given a binary matrix image, flip each row horizontally and then invert (0→1, 1→0). Return the resulting image.
For each row, use two pointers from both ends. Swap elements while XOR-ing with 1 to flip and invert simultaneously. When pointers meet at the middle (odd length), just flip the middle element.
- Use two pointers lo and hi for each row.
- While lo < hi: swap arr[lo] and arr[hi] and XOR both with 1.
- When lo == hi (middle of odd-length row): flip arr[lo] ^= 1.
- Process all rows.
- Time Complexity: O(M*N)
- Space Complexity: O(1) in-place