Matrices pattern

Set Matrix Zeroes

Given an m x n matrix, if any element is 0 set its entire row and column to 0, modifying the matrix in place. Watch it run step by step, then write your own pseudocode and get it checked by AI.

  • LeetCode 73
  • Medium
  • 2 approaches

Sign in with Google or GitHub and you land straight on this page. DSA comes with the all labs plan and every ChaiCode batch.

MatricesLeetCode 73

Medium

From the first idea to the best one

  1. 01 Brute force · row & column sets O(R·C)O(R + C) space
  2. 02 Optimized · markers in first row/col O(R·C)O(1) space
Each approach plays step by step, with its time and space.

What you will learn

  • How to read Set Matrix Zeroes and spot the matrices pattern in it
  • Brute force · row & column sets: O(R·C) time, O(R + C) space
  • Optimized · markers in first row/col: O(R·C) time, O(1) space
  • The pseudocode for each approach, its line lit as the animation runs
  • Practice: write your own pseudocode and get it checked

More Matrices

See Set Matrix Zeroes run, step by step

Sign in and this page opens on the animation, with all 5 Matrices problems beside it.

DSA comes with the all labs plan and every ChaiCode batch.