100186. Zero Matrix LCCI
2026/1/12小于 1 分钟约 130 字
100186. Zero Matrix LCCI
难度: Medium
题目描述
Write an algorithm such that if an element in an MxN matrix is 0, its entire row and column are set to 0.
Example 1:
Input: [ [1,1,1], [1,0,1], [1,1,1] ] Output: [ [1,0,1], [0,0,0], [1,0,1] ]
Example 2:
Input: [ [0,1,2,0], [3,4,5,2], [1,3,1,5] ] Output: [ [0,0,0,0], [0,4,5,0], [0,3,1,0] ]
解题思路
代码实现
解决方案
java
class Solution {
public void setZeroes(int[][] matrix) {
}
}