这道题首先想到把数字反转,再0,1转换。
class Solution { public int[][] flipAndInvertImage(int[][] A) { int i,j; int c = A.length; int temp; for(i = 0;i <= c-1;i++) { int c1 = A[i].length; for(j = 0;j <= (c1-1)/2;j++) { temp = A[i][j]; A[i][j] = A[i][c1-j-1]; A[i][c1-j-1] = temp; } } for(i = 0;i <= c-1;i++) { int c1 = A[i].length; for(j = 0;j <= c1-1;j++) { if(A[i][j] == 0) { A[i][j] = 1; } else { A[i][j] = 0; } } } return A; } }