Python3 - Beats 99.78% with explanation
\ndef flipAndInvertImage(self, A):\n\tfor row in A:\n\t\ti, j = 0, len(row) - 1\n\t\twhile i <= j:\n\t\t\tif row[i] == row[j]:\n\t\t\t\trow[i], row[j] = row[i]^
```\ndef flipAndInvertImage(self, A):\n\tfor row in A:\n\t\ti, j = 0, len(row) - 1\n\t\twhile i <= j:\n\t\t\tif row[i] == row[j]:\n\t\t\t\trow[i], row[j] = row[i]^1, row[j]^1\n\t\t\ti += 1\n\t\t\tj -= 1\n\treturn A\n```\n\n\nAfter reviewing some examples you will notice the following patterns:\n\t\t1) Look at first and last value of row.  If they are the same (1,1 or 0,0), they will be flipped in the output.  \n\t\t\tIf they are different (1,0 or 0,1), they do not change.  Work your way inward to the middle of the list \n\t\t\tapplying this rule.\n\t\t2) If the row has an odd number of entries, the middle value always flips.  For example if len(row) = 5, \n\t\t\tthen row[2] must change values.\n\nBitwise XOR --> 0^1 = 1, 1^1 =0 \n\nLet i be the index at the beginning of the row, and j be the index at the end of the row.  If the the values at \nthese indices (row[i] and row[j]) are equal, flip their values using XOR ^.  If they values are not equal, do \nnothing and move i and j closer to the middle.  When i == j , the code still executes as it should. \n\n**Edit**:\nIf `len(A) = num_words = M` and `len(A[0]) = word_length = N`, we iterate over `(word_length / 2) * num_words` or `(N/2) * M` values.  Time complexity is `O((N/2) * M)`, but its still just linear with the input so we can generalize as `O(N)`.  Space complexity is `O(1)`.
[]