Flipping an Image | Java - updated
\nclass Solution \n{\n    /* Pretty straight foreword.  Grab one row from the matrix at a time.  Set a pointer to the \n     * first element and the last elemen
```\nclass Solution \n{\n    /* Pretty straight foreword.  Grab one row from the matrix at a time.  Set a pointer to the \n     * first element and the last element in the row.  If the elements pointed at are of different\n     * values performing a swap would flip the values in the first and last pointers, then \n     * performing an invert would flip them back.  It would be as though nothing had happened.  If\n     * both the first and last values are the same the swap would maintain the value and the \n     * invert would flip them.  They\'re the same so no need to swap, just flip thier values.  Then\n     * update pointers one step towords the center.\n     */\n    \n    public int[][] flipAndInvertImage(int[][] A) \n    {\n        for( int[] r : A )\n        {\n            int     i = -1;\n            int     j = r.length;\n            \n            while( ++i <= --j )\n            {\n                if( r[ i ] == r[ j ] )\n                {\n                    r[ j ] = r[ i ] = 1 ^ r[ i ];\n                }\n            }\n        }\n        \n        return A;\n    }\n}\n```
[]