Matrix
LeetCode 36: Valid Sudoku
·2 mins
LeetCode
Medium
Array
Hash-Table
Matrix
LeetCode 36 note: each digit may appear once per row, column and 3 × 3 box; put (digit, row), (digit, column) and (digit, box) keys into one set
LeetCode 892: Surface Area of 3D Shapes
·2 mins
LeetCode
Easy
Array
Math
Geometry
Matrix
LeetCode 892 note: a stack of v cubes has 4v + 2 faces; subtract 2 × min for each overlap with the stacks above and to the left
LeetCode 883: Projection Area of 3D Shapes
·1 min
LeetCode
Easy
Array
Math
Geometry
Matrix
LeetCode 883 note: the top view counts nonzero cells, and the front and side views sum each row’s and each column’s maximum
LeetCode 867: Transpose Matrix
·1 min
LeetCode
Easy
Array
Matrix
Simulation
LeetCode 867 note: the transpose is n × m with res[j][i] = matrix[i][j]; in Python, zip(*matrix)
LeetCode 832: Flipping an Image
·2 mins
LeetCode
Easy
Array
Two-Pointers
Bit-Manipulation
Matrix
LeetCode 832 note: reverse each row and invert its bits, which two pointers can do at once
LeetCode 766: Toeplitz Matrix
·2 mins
LeetCode
Easy
Array
Matrix
LeetCode 766 note: every diagonal is constant exactly when each cell equals its upper-left neighbor
LeetCode 733: Flood Fill
·2 mins
LeetCode
Easy
Array
Depth-First-Search
Breadth-First-Search
Matrix
LeetCode 733 note: DFS or BFS from the start, recoloring 4-directional cells that share the start’s original color; return immediately if the colors are equal
LeetCode 661: Image Smoother
·2 mins
LeetCode
Easy
Array
Matrix
LeetCode 661 note: each cell becomes the floored average of the existing cells in its 3 × 3 neighborhood, written into a new matrix
LeetCode 566: Reshape the Matrix
·2 mins
LeetCode
Easy
Array
Matrix
Simulation
LeetCode 566 note: return the original if the element counts differ; otherwise element k goes to (k // c, k % c)
LeetCode 463: Island Perimeter
·2 mins
LeetCode
Easy
Array
Depth-First-Search
Breadth-First-Search
Matrix
LeetCode 463 note: each land cell contributes 4 edges, minus 2 for each land neighbor above or to the left