---
# System prepended metadata

title: 2128. Remove All Ones With Row and Column Flips
tags: [Leetcode, Medium]

---

# 2128. Remove All Ones With Row and Column Flips
###### tags: `Leetcode` `Medium`
Link: https://leetcode.com/problems/remove-all-ones-with-row-and-column-flips/
## 思路
对于任意两个row来说
要不就是两个row完全相同 要不就是两个row完全相反
## Code
```java=
class Solution {
    public boolean removeOnes(int[][] grid) {
        for(int i=1; i<grid.length; i++){
            for(int j=1; j<grid[0].length; j++){
                if(Math.abs(grid[i][j]-grid[0][j])!=Math.abs(grid[i][j-1]-grid[0][j-1])) return false;
            }
        }
        return true;
    }
}
```