Set matrix zeroes

Problem If any element of an m x n matrix is 0, set its entire row and column to 0 — in place.

Input / Output

  • Input: int matrix. Output: matrix mutated in place.

Constraints

  • m, n up to 200; the ask escalates by space: O(m+n) extra is easy, O(1) extra is the real question.

Example

  • [[1,1,1],[1,0,1],[1,1,1]] → [[1,0,1],[0,0,0],[1,0,1]].
asked …
LeaderboardSalaryAccount