Class Solution
java.lang.Object
g0001_0100.s0073_set_matrix_zeroes.Solution
73 - Set Matrix Zeroes.<p>Medium</p>
<p>Given an <code>m x n</code> integer matrix <code>matrix</code>, if an element is <code>0</code>, set its entire row and column to <code>0</code>’s, and return <em>the matrix</em>.</p>
<p>You must do it <a href="https://en.wikipedia.org/wiki/In-place_algorithm" target="_top">in place</a>.</p>
<p><strong>Example 1:</strong></p>
<p><img src="https://assets.leetcode.com/uploads/2020/08/17/mat1.jpg" alt="" /></p>
<p><strong>Input:</strong> matrix = [[1,1,1],[1,0,1],[1,1,1]]</p>
<p><strong>Output:</strong> [[1,0,1],[0,0,0],[1,0,1]]</p>
<p><strong>Example 2:</strong></p>
<p><img src="https://assets.leetcode.com/uploads/2020/08/17/mat2.jpg" alt="" /></p>
<p><strong>Input:</strong> matrix = [[0,1,2,0],[3,4,5,2],[1,3,1,5]]</p>
<p><strong>Output:</strong> [[0,0,0,0],[0,4,5,0],[0,3,1,0]]</p>
<p><strong>Constraints:</strong></p>
<ul>
<li><code>m == matrix.length</code></li>
<li><code>n == matrix[0].length</code></li>
<li><code>1 <= m, n <= 200</code></li>
<li><code>-2<sup>31</sup> <= matrix[i][j] <= 2<sup>31</sup> - 1</code></li>
</ul>
<p><strong>Follow up:</strong></p>
<ul>
<li>A straightforward solution using <code>O(mn)</code> space is probably a bad idea.</li>
<li>A simple improvement uses <code>O(m + n)</code> space, but still not the best solution.</li>
<li>Could you devise a constant space solution?</li>
</ul>
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
Solution
public Solution()
-
-
Method Details
-
setZeroes
public void setZeroes(int[][] matrix)
-