Skip to content
Optimal Lab

Practice · 5 problems

Matrix

0 of 5 solved on this device

  1. 133Spiral MatrixGiven an m x n matrix, return all its elements in spiral order: right across the top, down the right side, left across the bottom, up the left side, then inward.Medium
  2. 134Set Matrix ZeroesGiven an m x n matrix, if an element is 0 set its entire row and column to 0. You must do it IN PLACE.Medium
  3. 135Search a 2D MatrixGiven an m x n matrix where each row is sorted ascending and the first value of each row is greater than the last value of the previous row, return true if `target` is present. Must run in O(log(m * n)) time.Medium
  4. 136Valid SudokuDetermine whether a 9 x 9 Sudoku board is valid. Only the filled cells need checking: each row, each column and each of the nine 3 x 3 sub-boxes must contain the digits 1-9 without repetition. The board need not be solvable.Medium
  5. 137Game of LifeGiven an m x n board of 1 (live) and 0 (dead) cells, compute the next state under Conway's rules: a live cell with fewer than 2 or more than 3 live neighbors dies, a live cell with 2 or 3 survives, and a dead cell with exactly 3 becomes live. All cells update SIMULTANEOUSLY, and you should do it in place.Medium