Skip to content

Instantly share code, notes, and snippets.

@snmslavk

snmslavk/832

Created Aug 16, 2018
Embed
What would you like to do?
class Solution {
public int[][] flipAndInvertImage(int[][] A) {
// reverse
for( int i = 0; i < A.length; i++)
{
for( int j = 0; i < A[i].length / 2; i++)
{
int len = A[i].length;
int tmp = A[i][j];
A[i][j] = A[i][len - j - 1];
A[i][len - j - 1] = tmp;
}
}
// invert
System.out.println("invert");
for( int i = 0; i < A.length; i++)
{
for( int j = 0; j < A[i].length; j++)
{
A[i][j] ^= 1;
}
}
return A;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment