1.
Valid Sudoku (Medium)
Determine if a 9 x 9
Sudoku board is valid. Only the filled cells need to be validated according to the following rules:
- Each row must contain the digits
1-9
without repetition. - Each column must contain the digits
1-9
without repetition. - Each of the nine
3 x 3
sub-boxes of the grid must contain the digits1-9
without repetition.
Note:
- A Sudoku board (partially filled) could be valid but is not necessarily solvable.
- Only the filled cells need to be validated according to the mentioned rules.
2.
Spiral Matrix (Medium)
Given an m x n
matrix
, return all elements of the matrix
in spiral order.
3.
Rotate Image (Medium)
You are given an n x n
2D matrix
representing an image, rotate the image by 90 degrees (clockwise).
Rotate the image in-place.
4.
Set Matrix Zeroes (Medium)
Given an m x n
integer matrix matrix
, if an element is 0
, set its entire row and column to 0
's.
Modify the matrix in place.
5.
Game of Life (Medium)
"The Game of Life, also known simply as Life, is a cellular automaton devised by the British mathematician John Horton Conway in 1970."
The board is made up of an m x n
grid of cells, where each cell has an initial state: live (represented by a 1
) or dead (represented by a 0
). Each cell interacts with its eight neighbors (horizontal, vertical, diagonal) using the following four rules:
- Any live cell with fewer than two live neighbors dies as if caused by under-population.
- Any live cell with two or three live neighbors lives on to the next generation.
- Any live cell with more than three live neighbors dies, as if by over-population.
- Any dead cell with exactly three live neighbors becomes a live cell, as if by reproduction.
The next state is created by applying the above rules simultaneously to every cell in the current state, where births and deaths occur simultaneously. Given the current state of the m x n
grid board
, return the next state.