思路
1.遍历原数组, 当碰到元素为0时
- 记录这个元素对应的行下标,在数组row[]的对应位置设成true
- 记录这个元素对应的列下标,保存在数组col[]的对应位置设成true
2.遍历row和col数组,对原数组的对应行和列的位置进行置零
具体看我代码里的注释啦
class Solution {
public void setZeroes(int[][] matrix) {
int m = matrix.length, n = matrix[0].length;
boolean[] row = new boolea