Given a m x n matrix, if an element is 0, set its entire row and column to 0. Do it in place.
Copied method from:http://www.programcreek.com/2012/12/leetcode-set-matrix-zeroes-java/
This problem can solve by following 4 steps:
- check if first row and column are zero or not
- mark zeros on first row and column
- use mark to set elements
- set first column and row by using marks in step 1
Becareful of first row and column
本文介绍了一种优化方法,通过四个步骤解决给定矩阵中元素为零时,将其所在行和列全部置零的问题。此方法在不使用额外空间的情况下,通过标记首行和首列来实现矩阵元素的批量置零,确保了算法的效率和空间复杂度的优化。
123

被折叠的 条评论
为什么被折叠?



