matrix
matrix is one of the most repeated interview dimensions. Start with edge-safe fundamentals, then move into pattern-level trade-offs.
Interview Signal
Frequently tests problem modeling, edge handling, and verbal clarity.
Common Pitfall
Template-only answers break under follow-up questioning.
Practice Strategy
Practice in 3-5 problem rounds and always review complexity alternatives.
Recommended Progression
Pattern Bridge
High-Pressure Round
Valid Sudoku
Check if a 9x9 Sudoku board is valid by scanning rows, columns, and sub-boxes with hash lookups, ensuring no duplicates …
Sudoku Solver
Solve the Sudoku puzzle by filling empty cells while respecting Sudoku's rules using array scanning and backtracking.
Rotate Image
Rotate an n x n matrix 90 degrees clockwise in-place using array manipulation and mathematical indexing techniques effic…
Spiral Matrix
Given an m x n matrix, return all elements in spiral order starting from the top-left corner.
Spiral Matrix II
Generate a spiral matrix of size n x n, filled with elements from 1 to n² in spiral order, for interview-focused solving…
Unique Paths II
Calculate the number of unique paths from top-left to bottom-right in a grid with obstacles using dynamic programming st…
Minimum Path Sum
Compute the minimum sum from top-left to bottom-right in a grid using state transition dynamic programming efficiently.
Set Matrix Zeroes
Modify the matrix in place by setting rows and columns to zero when an element is zero.
Search a 2D Matrix
Search a 2D matrix efficiently using binary search over its linearized index, ensuring correctness in row-major sorted a…
Word Search
Solve Word Search with backtracking by exploring adjacent cells to match a target word in a grid.
Maximal Rectangle
Compute the largest rectangle of 1's in a binary matrix using dynamic programming and stack-based state transitions effi…
Surrounded Regions
Transform the matrix in-place by marking regions surrounded by 'X' as 'X', while keeping border-adjacent 'O's intact.
Dungeon Game
Calculate the minimum initial health the knight needs to survive the dungeon using state transition dynamic programming …
Number of Islands
Count the number of distinct islands in a binary grid using array traversal combined with depth-first search exploration…
Word Search II
Solve the Word Search II problem using backtracking with pruning to find all words on a board of characters.
Maximal Square
Maximal Square is a matrix-based dynamic programming problem that focuses on finding the largest square filled with 1's.
Search a 2D Matrix II
Efficiently search for a target in a 2D matrix using binary search and matrix properties.
Game of Life
Solve the Game of Life by updating each cell based on its eight neighbors using Array and Matrix simulation patterns eff…
Range Sum Query 2D - Immutable
Design a 2D matrix class that efficiently handles sum queries with O(1) time complexity using a prefix sum approach.
Longest Increasing Path in a Matrix
Find the length of the longest increasing path in a matrix with given movement constraints using graph techniques.
Max Sum of Rectangle No Larger Than K
Solve the "Max Sum of Rectangle No Larger Than K" problem using binary search over the valid sum space to optimize space…
Kth Smallest Element in a Sorted Matrix
Find the kth smallest element in a sorted n x n matrix using efficient binary search or heap strategies for optimized me…
Trapping Rain Water II
Solve Trapping Rain Water II using breadth-first search and priority queues for efficient water trapping in a matrix.
Pacific Atlantic Water Flow
Find all cells on an island where water can flow to both the Pacific and Atlantic oceans using DFS or BFS.
Battleships in a Board
Count the number of non-overlapping battleships on a 2D board using array traversal and depth-first search patterns effi…
Construct Quad Tree
Construct a Quad-Tree from a binary matrix by recursively subdividing regions and tracking uniform states efficiently.
Island Perimeter
Determine the perimeter of an island in a grid of land and water cells using DFS or BFS.
Diagonal Traverse
Traverse a matrix diagonally and return all elements in the specific zig-zag order required by the problem pattern.
Minesweeper
Solve the Minesweeper game by updating revealed squares and handling clicks with Depth-First Search and Array manipulati…
01 Matrix
The '01 Matrix' problem challenges you to find the nearest zero for each cell in a binary matrix using dynamic programmi…
Reshape the Matrix
Reshape the Matrix involves transforming a 2D matrix into a new matrix with the same elements in row-major order, follow…
Image Smoother
Apply a 3x3 smoothing filter to a matrix, rounding down each cell average including surrounding neighbors for accurate r…
Cut Off Trees for Golf Event
Determine the minimum steps to cut all trees in a forest matrix in ascending height order using BFS traversal and priori…
Max Area of Island
Find the largest connected land area in a binary grid using array traversal and depth-first search efficiently.
Flood Fill
Flood Fill is an array and DFS problem where you change connected pixels to a target color efficiently using recursion o…
Cherry Pickup
Maximize cherries collected on a grid, employing state transition dynamic programming with careful navigation across obs…
Contain Virus
Contain Virus involves using array-based Depth-First Search to contain viral spread by building walls around infected re…
Toeplitz Matrix
Determine if a given matrix is a Toeplitz matrix by checking diagonal consistency.
Sliding Puzzle
Determine the minimum moves to solve a 2x3 sliding puzzle using BFS and state transition dynamic programming techniques …
Swim in Rising Water
Solve the problem of swimming through a grid of rising water with a binary search on the valid answer space.
Transform to Chessboard
Determine the minimum swaps of rows or columns to convert an n x n binary board into a valid chessboard configuration.
Valid Tic-Tac-Toe State
Verify if a given Tic-Tac-Toe board can represent a valid game state during a valid sequence of moves.
Bricks Falling When Hit
Bricks Falling When Hit challenges your ability to simulate brick falls after sequential erasures using Union Find.
Max Increase to Keep City Skyline
Maximize building heights in a city grid without changing the skyline, using greedy selection constrained by row and col…
Making A Large Island
Calculate the largest island size by converting at most one zero in a binary grid using array and DFS techniques efficie…
Flipping an Image
Flip each row of a binary matrix horizontally and invert its values efficiently using a two-pointer scanning approach.
Image Overlap
Image Overlap requires calculating the overlap between two binary matrices by translating one image over the other.
Magic Squares In Grid
Scan every 3x3 window, reject invalid digits fast, then verify row, column, and diagonal sums for Magic Squares In Grid.
Score After Flipping Matrix
Maximize the score of a binary matrix by flipping rows and columns using a greedy approach and validation of invariants.
Shortest Path to Get All Keys
Find the minimum steps to collect all keys in a grid using BFS and bitmasking, handling locks efficiently.
Transpose Matrix
Transpose Matrix problem requires flipping a matrix's rows and columns to return the transposed version.
Projection Area of 3D Shapes
Calculate the projection area of a 3D shape defined by a grid of towers with varying heights.
Spiral Matrix III
Solve the Spiral Matrix III problem by simulating the movement across a matrix with specific constraints on direction an…
Surface Area of 3D Shapes
Solve the Surface Area of 3D Shapes problem using array manipulation and mathematical formulas to calculate surface area…
Snakes and Ladders
Solve the Snakes and Ladders problem using a BFS strategy to efficiently navigate the board and reach the final square.
Minimum Falling Path Sum
Minimum Falling Path Sum is a matrix dynamic programming problem where each cell depends on three reachable cells above …
Shortest Bridge
Find the minimum flips to connect two separate islands in a binary matrix using Array and DFS techniques efficiently.
Regions Cut By Slashes
Determine the number of regions in a grid divided by slashes using array scanning and union-find techniques efficiently.
Unique Paths III
Solve the Unique Paths III problem using backtracking search with pruning to count 4-directional paths covering all empt…
Rotting Oranges
Given a grid with fresh and rotten oranges, return the minimum time for all oranges to rot or -1 if impossible.
Available Captures for Rook
This problem involves finding the number of pawns a rook can capture on a chessboard, considering obstacles like bishops…
Number of Enclaves
This problem involves finding the number of land cells that cannot reach the boundary in a grid using DFS and array mani…
Matrix Cells in Distance Order
Compute all matrix cell coordinates sorted by Manhattan distance from a given center using array and math techniques eff…
Coloring A Border
Given a grid and a starting cell, color all border cells of the connected component using DFS while preserving interior …
Flip Columns For Maximum Number of Equal Rows
Maximize the number of equal rows in a binary matrix by flipping any number of columns.
Number of Submatrices That Sum to Target
Count all non-empty submatrices in a given matrix whose elements sum exactly to the target using efficient scanning tech…
Shortest Path in Binary Matrix
Find the shortest clear path in a binary matrix using BFS, carefully handling obstacles and diagonal movements for effic…
Largest 1-Bordered Square
Find the largest square of 1s with 1s on its borders in a binary grid using dynamic programming.
As Far from Land as Possible
Find the farthest water cell from land in a grid and return the Manhattan distance using state transition dynamic progra…
Minimum Moves to Reach Target with Rotations
Find the minimum moves for a 2-cell snake to reach the bottom-right corner using rotations and BFS traversal in a grid.
Path with Maximum Gold
Find the path with the maximum gold in a grid with backtracking and pruning techniques to maximize the gold collected.
Queens That Can Attack the King
Identify all black queens on an 8x8 chessboard that can attack the white king using array and matrix simulation techniqu…
Reconstruct a 2-Row Binary Matrix
Reconstruct a 2-row binary matrix by distributing column sums while respecting upper and lower row limits using greedy p…
Number of Closed Islands
Count the number of closed islands in a 2D grid using array traversal and depth-first search efficiently.
Shift 2D Grid
Shift 2D Grid requires shifting elements of a matrix by a given number of times, simulating step-by-step movement.
Minimum Moves to Move a Box to Their Target Location
Solve the minimum moves to push a box to its target using BFS and priority handling in a grid-based warehouse layout eff…
Count Servers that Communicate
Count Servers that Communicate involves identifying servers in a grid that can communicate based on row or column connec…
Find Winner on a Tic Tac Toe Game
Determine the winner of a Tic Tac Toe game by scanning moves and using hash lookups for rows, columns, and diagonals eff…
Count Square Submatrices with All Ones
Count the number of square submatrices with all ones in a given binary matrix using dynamic programming.
Minimum Number of Flips to Convert Binary Matrix to Zero Matrix
Compute the minimum flips to convert a binary matrix to zero by toggling cells and neighbors using array scanning plus h…
Minimum Falling Path Sum II
Find the minimum sum of a falling path in a square matrix using dynamic programming while avoiding same-column selection…
Maximum Side Length of a Square with Sum Less than or Equal to Threshold
This problem challenges you to find the largest square in a matrix with a sum below a given threshold using binary searc…
Shortest Path in a Grid with Obstacles Elimination
Find the shortest path in a grid with obstacles, allowing the elimination of up to k obstacles using BFS.
Number of Paths with Max Score
Calculate the maximum score path and count all valid routes in a square board with obstacles using dynamic programming.
Matrix Block Sum
Compute a matrix where each cell contains the sum of all elements within k-distance blocks using prefix sums efficiently…
Sort the Matrix Diagonally
Sort each diagonal of a matrix in ascending order, applying sorting and matrix traversal techniques.
The K Weakest Rows in a Matrix
Find the k weakest rows in a binary matrix where rows contain soldiers and civilians, using sorting and binary search te…
Maximum Students Taking Exam
Calculate the maximum number of students who can take an exam without cheating using state transition dynamic programmin…
Count Negative Numbers in a Sorted Matrix
Count Negative Numbers in a Sorted Matrix requires counting negative numbers in a matrix sorted in non-increasing order …
Minimum Cost to Make at Least One Valid Path in a Grid
Determine the minimum cost to create at least one valid path from the top-left to bottom-right in a directional grid.
Lucky Numbers in a Matrix
The Lucky Numbers in a Matrix problem involves finding elements that are the minimum in their row and maximum in their c…
Check if There is a Valid Path in a Grid
Check if there is a valid path from the upper-left to the bottom-right corner of a grid using depth-first search.
Find the Kth Smallest Sum of a Matrix With Sorted Rows
Find the kth smallest sum in a matrix with sorted rows using binary search and a heap-based approach.
Number of Ways of Cutting a Pizza
This problem challenges you to determine the number of valid ways to cut a pizza into pieces with apples using dynamic p…
Cherry Pickup II
Maximize cherry collection in a grid using two robots with careful state transition dynamic programming to optimize path…
Subrectangle Queries
Implement the SubrectangleQueries class to handle dynamic updates and value queries on a 2D rectangle.
Count Submatrices With All Ones
Count Submatrices With All Ones is a dynamic programming problem focusing on submatrix counting using an efficient row-b…
Minimum Swaps to Arrange a Binary Grid
Compute the minimum number of adjacent row swaps to transform a binary grid so all upper-triangle cells are zero using a…
Detect Cycles in 2D Grid
Detect cycles in a 2D character grid using DFS while carefully tracking parent cells to avoid invalid revisits.
Minimum Number of Days to Disconnect Island
Find the minimum number of days to disconnect an island in a grid using depth-first search.
Matrix Diagonal Sum
Calculate the sum of both primary and secondary diagonals in a square matrix while avoiding double-counting overlaps.
Special Positions in a Binary Matrix
Identify all special positions in a binary matrix where a 1 has no other 1s in its row or column, ensuring optimal array…
Strange Printer II
Solve Strange Printer II by building color dependencies from bounding rectangles and checking whether a topological orde…
Maximum Non Negative Product in a Matrix
Find the maximum non-negative product path in a matrix using dynamic programming and state transition.
Minimum Cost to Connect Two Groups of Points
Compute the minimum cost to fully connect two groups of points using dynamic programming and bitmasking efficiently.
Find Valid Matrix Given Row and Column Sums
Given row and column sums, find any valid matrix of non-negative integers that satisfies them.
Path With Minimum Effort
Find the minimum effort required to travel from the top-left to the bottom-right of a grid, considering height differenc…
Rank Transform of a Matrix
Compute a unique rank matrix using graph indegree with topological ordering, ensuring each element reflects its relative…
Richest Customer Wealth
Calculate the richest customer's wealth by summing the amounts in each customer's bank accounts in a matrix.
Where Will the Ball Fall
Determine where each ball exits a diagonal board grid or if it gets stuck, using matrix simulation with careful traversa…
Largest Submatrix With Rearrangements
Rearrange columns of a binary matrix to find the largest submatrix of 1s.
Cat and Mouse II
Cat and Mouse II requires determining if the mouse can reach food before being caught using graph and topological orderi…
Find Kth Largest XOR Coordinate Value
Compute the kth largest XOR coordinate in a 2D matrix using prefix sums, bit manipulation, and optimized selection techn…
Map of Highest Peak
Solve the Map of Highest Peak problem using breadth-first search to assign heights based on proximity to water cells.
Rotating the Box
Rotate a box represented by a character matrix, letting stones fall under gravity using precise two-pointer scanning and…
Get Biggest Three Rhombus Sums in a Grid
Find the three largest distinct rhombus sums from a given grid using array and math techniques.
Determine Whether Matrix Can Be Obtained By Rotation
Determine if a binary matrix can be transformed into another by rotating it 90 degrees multiple times.
Largest Magic Square
Find the side length of the largest magic square in a matrix where row, column, and diagonal sums are equal.
Find a Peak Element II
Locate any peak in a 2D matrix using binary search across rows or columns for efficient discovery and verification.
Count Sub Islands
Identify and count all islands in grid2 that are fully contained within islands of grid1 using DFS traversal efficiently…
Cyclically Rotating a Grid
This problem requires cyclically rotating a grid by rotating each layer of the matrix counter-clockwise for a specified …
Nearest Exit from Entrance in Maze
Find the shortest path from the maze entrance to the nearest border exit using BFS over a 2D array matrix efficiently.
Maximum Number of Points with Cost
Maximize your points in a matrix by selecting cells row by row while accounting for distance penalties using dynamic pro…
Check if Move is Legal
Determine if a move on an 8x8 board is legal by validating lines in all directions using array and matrix patterns.
Last Day Where You Can Still Cross
Find the last day to walk from top to bottom in a flooded matrix by using binary search and graph traversal techniques.
Maximum Matrix Sum
Maximize the sum of an n x n integer matrix using row and column negation operations efficiently with a greedy approach.
Minimize the Difference Between Target and Chosen Elements
This problem asks to select one element per row to minimize the absolute difference from a target sum using dynamic prog…
Find All Groups of Farmland
Identify all rectangular farmland groups in a binary matrix using array traversal and depth-first search efficiently.
Grid Game
Solve the Grid Game problem by optimizing the movement of two robots on a 2D matrix grid.
Check if Word Can Be Placed In Crossword
Determine if a word fits in a crossword grid using array and matrix checks, accounting for spaces, letters, and blocked …
Convert 1D Array Into 2D Array
Convert a 1D integer array into a structured 2D array with specified rows and columns using all elements sequentially.
Minimum Operations to Make a Uni-Value Grid
Determine the fewest additions or subtractions of x to make all grid elements identical using array and math logic.
Count Fertile Pyramids in a Land
Solve Count Fertile Pyramids in a Land with matrix DP that measures the tallest pyramid rooted at each fertile cell.
Number of Laser Beams in a Bank
Calculate total laser beams in a bank floor plan using array counting and math logic between security devices on differe…
Stamping the Grid
Determine if a binary grid can be fully covered using fixed-size stamps by applying a greedy placement and validation st…
Check if Every Row and Column Contains All Numbers
Determine if every row and column in a square matrix contains all numbers from 1 to n without repetition using array sca…
K Highest Ranked Items Within a Price Range
Use BFS to rank reachable shop items by distance, price, row, and column, then return the best k coordinates.
Maximum Trailing Zeros in a Cornered Path
Find the maximum trailing zeros in the product of a cornered path within a 2D grid.
Count Unguarded Cells in the Grid
Solve Count Unguarded Cells in the Grid by marking guard sight lines across a blocked matrix and counting untouched empt…
Escape the Spreading Fire
Maximize the time you can stay at your starting position before moving to safely reach the safehouse while avoiding fire…
Check if There Is a Valid Parentheses String Path
Check if there exists a valid parentheses string path in a given grid using state transition dynamic programming.
Minimum Obstacle Removal to Reach Corner
Find the minimum obstacles to remove in a 2D grid to reach the bottom-right corner using BFS graph traversal techniques.
Minimum Path Cost in a Grid
Minimize the cost of a path in a grid while considering move costs for each step.
Check if Matrix Is X-Matrix
Check if a square matrix follows the X-Matrix pattern by validating diagonal and non-diagonal conditions.
Spiral Matrix IV
In this problem, you need to generate a matrix filled with values from a linked list in a spiral order.
Number of Increasing Paths in a Grid
Solve Number of Increasing Paths in a Grid by turning cell comparisons into a DAG and counting paths with topological DP…
Equal Row and Column Pairs
Identify all pairs of rows and columns in a square matrix that contain identical elements in the same sequence efficient…
Largest Local Values in a Matrix
Find the largest value in every 3x3 submatrix of an n x n integer matrix efficiently using nested loops.
Build a Matrix With Conditions
Solve the matrix-building problem by using graph indegree and topological sorting to satisfy given row and column constr…
Maximum Rows Covered by Columns
Select exactly numSelect columns from a binary matrix to maximize rows where all ones are covered efficiently using back…
Maximum Sum of an Hourglass
Calculate the maximum sum of an hourglass in a 2D matrix using array traversal and submatrix evaluation techniques effic…
Paths in Matrix Whose Sum Is Divisible by K
Compute all paths in a matrix where the sum of elements is divisible by k using state transition dynamic programming eff…
Difference Between Ones and Zeros in Row and Column
This problem requires computing a difference matrix based on the ones and zeros in each row and column of a binary matri…
Delete Greatest Value in Each Row
Calculate the total of removed maximum values from each row of a matrix, iterating until all columns are deleted efficie…
Maximum Number of Points From Grid Queries
Solve the Maximum Number of Points From Grid Queries problem using two-pointer scanning and invariant tracking.
Increment Submatrices by One
Increment Submatrices by One focuses on efficiently updating submatrices using row-wise prefix sums in an n by n matrix.
Sort the Students by Their Kth Score
Sort a matrix of student scores by the kth exam efficiently using array manipulation and custom sorting techniques.
Disconnect Path in a Binary Matrix by at Most One Flip
Determine if a single cell flip can disconnect a path from the top-left to bottom-right in a binary matrix efficiently u…
Find the String with LCP
Determine the lexicographically smallest string matching a given LCP matrix using state transition dynamic programming.
Minimum Time to Visit a Cell In a Grid
Compute the fastest path in a grid where each cell has a minimum time requirement using BFS and priority queue technique…
Check Knight Tour Configuration
Validate a knight's movement configuration on an n x n chessboard to check if it forms a valid Knight's Tour.
Prime In Diagonal
Find the largest prime number located on any diagonal of a square matrix using array iteration and prime checking techni…
Minimum Number of Visited Cells in a Grid
Determine the minimum number of cells to visit in a grid using state transition dynamic programming and efficient traver…
Find the Width of Columns of a Grid
This problem asks you to compute the width of each column in a grid, where the width is defined by the length of the lar…
Row With Maximum Ones
Find the row with the maximum ones in a binary matrix and return its index and count.
Maximum Number of Fish in a Grid
Maximize the number of fish that can be caught by performing DFS on an optimal starting point in a grid.
First Completely Painted Row or Column
Find the first index where a row or column is completely painted in a matrix based on an array of integers.
Sum in a Matrix
Calculate the maximum score by repeatedly removing the largest elements from each row of a 2D matrix efficiently using s…
Maximum Number of Moves in a Grid
Maximize the number of moves in a grid starting from the first column using state transition dynamic programming.
Difference of Number of Distinct Values on Diagonals
Find the difference in the number of distinct diagonal values in a matrix, returning results in a new matrix.
Maximum Strictly Increasing Cells in a Matrix
Find the maximum number of cells that can be visited in a matrix by following strictly increasing values from a starting…
Find a Good Subset of the Matrix
Find a Good Subset of the Matrix is a challenging problem involving array scanning, hash lookup, and bit manipulation to…
Find the Safest Path in a Grid
Find the Safest Path in a Grid uses binary search and BFS to maximize path safeness from thieves in a grid.
Minimum Moves to Spread Stones Over Grid
Solve the problem of distributing 9 stones across a 3x3 grid with minimal moves using state transition dynamic programmi…
Construct Product Matrix
Solve the "Construct Product Matrix" problem by calculating the product of elements in 2D matrices without division.
Find Champion I
Find Champion I is an easy problem focusing on identifying the strongest team in a tournament using matrix-based compari…
Maximum Spending After Buying Items
Maximize spending by carefully choosing the right items across multiple shops over m * n days.
Matrix Similarity After Cyclic Shifts
Determine if a matrix returns to its original state after performing cyclic row shifts k times using array and math patt…
Find Missing and Repeated Values
Find the missing and repeated numbers in an n x n grid using array scanning and hash lookup.
Find the Grid of Region Average
Find the Grid of Region Average requires identifying regions in a matrix where pixel differences are below a threshold, …
Modify the Matrix
Modify the Matrix efficiently by replacing all -1 elements with the maximum in their column using array and matrix opera…
Most Frequent Prime
Find the most frequent prime over 10 from numbers generated by scanning a 2D matrix in all straight directions efficient…
Count Submatrices with Top-Left Element and Sum Less Than k
Count all submatrices including the top-left element with sum less than k using array and matrix prefix sum strategies.
Minimum Operations to Write the Letter Y on a Grid
Find the minimum number of operations to write the letter Y on a grid by altering cell values.
Minimum Number of Operations to Satisfy Conditions
This problem asks to find the minimum number of operations on a 2D grid using state transition dynamic programming effic…
Make a Square with the Same Color
Determine if a 3x3 grid can form a 2x2 square of the same color by changing at most one cell efficiently.
Check if Grid Satisfies Conditions
Check if a grid satisfies given conditions by analyzing array and matrix structure with specific checks on values.
Maximum Difference Score in a Grid
Maximize the score in a grid by making moves to the bottom or right, using state transition dynamic programming.
Find the Minimum Area to Cover All Ones I
Find the smallest rectangle to cover all 1's in a 2D binary matrix, focusing on array and matrix handling.
Find the Minimum Area to Cover All Ones II
Find the minimum area to cover all 1's in a 2D binary grid using three non-overlapping rectangles.
Count Submatrices With Equal Frequency of X and Y
Count the number of submatrices with equal frequency of 'X' and 'Y' in a 2D character grid.
Maximum Score From Grid Operations
Maximize your score by choosing the optimal sequence of column operations on a grid using dynamic programming transition…
Minimum Number of Flips to Make Binary Grid Palindromic I
Find the minimum flips to make a binary grid palindromic by scanning with two pointers and tracking symmetry efficiently…
Minimum Number of Flips to Make Binary Grid Palindromic II
The problem asks to flip cells in a binary grid to make its rows and columns palindromic using the minimum number of fli…
Design Neighbor Sum Service
Design a service that computes sums for adjacent and diagonal elements in a 2D grid.
Maximum Value Sum by Placing Three Rooks I
Maximize the value sum by placing three rooks on a chessboard while ensuring they do not attack each other.
Maximum Value Sum by Placing Three Rooks II
Maximize the sum by placing three non-attacking rooks on a chessboard with dynamic programming.
Select Cells in Grid With Maximum Score
Optimize selection of grid cells using state transition dynamic programming to maximize total sum efficiently.
Find a Safe Walk Through a Grid
Determine if you can safely traverse a binary grid from top-left to bottom-right using limited health points.
Construct 2D Grid Matching Graph Layout
This problem challenges you to construct a 2D grid from an undirected graph using a given set of edges.
Maximum Points Tourist Can Earn
Calculate the maximum points a tourist can earn by choosing optimal city moves over k days using state transition DP.
Find Minimum Time to Reach Last Room I
Find Minimum Time to Reach Last Room I challenges you to determine the minimum time to travel in a dungeon with a grid l…
Find Minimum Time to Reach Last Room II
Calculate the minimum time to reach the last room in a grid with alternating move times using array and graph patterns.
Find the Maximum Number of Fruits Collected
Maximize the number of fruits collected by three children navigating a grid dungeon with dynamic programming.
Count Paths With the Given XOR Value
Count the number of paths in a grid where the XOR of all values along the path equals a given number.
Minimum Operations to Make Columns Strictly Increasing
Calculate the minimum increments to make each column of a matrix strictly increasing using a greedy invariant approach.
Zigzag Grid Traversal With Skip
Traverse a 2D grid in a zigzag pattern while skipping alternate cells, focusing on array and matrix manipulation challen…
Maximum Amount of Money Robot Can Earn
Find the maximum amount of money a robot can collect while neutralizing robbers on its path in a grid.
Sort Matrix by Diagonals
Sort Matrix by Diagonals groups cells by diagonal, then sorts bottom-left diagonals descending and top-right diagonals a…
Length of Longest V-Shaped Diagonal Segment
Compute the maximum length of a V-shaped diagonal segment in a 2D integer matrix using state transition dynamic programm…
Maximum Sum With at Most K Elements
Find the maximum sum by selecting at most k elements from a 2D matrix respecting per-row limits using a greedy strategy.
Design Spreadsheet
Design a spreadsheet that supports setting, retrieving, and resetting values, with the ability to handle formulas refere…
Count Cells in Overlapping Horizontal and Vertical Substrings
Efficiently count grid cells appearing in both horizontal and vertical occurrences of a given string pattern using array…
Fill a Special Grid
Fill a Special Grid uses recursive divide-and-conquer to populate a 2^n x 2^n matrix with sequential integers uniquely i…
Equal Sum Grid Partition I
Determine if an m x n matrix grid can be split into two non-empty sections with equal sums by making a single horizontal…
Equal Sum Grid Partition II
Determine if a matrix can be partitioned into two sections with an equal sum using a single cut.
Grid Teleportation Traversal
Find the minimum moves to traverse a 2D grid using standard steps and one-time portal teleports efficiently.
Minimum Absolute Difference in Sliding Submatrix
Find the minimum absolute difference in each k x k submatrix within a given 2D grid using array and sorting techniques.
Minimum Moves to Clean the Classroom
Solve the "Minimum Moves to Clean the Classroom" problem using array scanning and hash lookup for an optimized solution.
Minimum Cost Path with Alternating Directions II
This problem focuses on finding the minimum cost path with alternating directions in a grid using dynamic programming.
Count Islands With Total Value Divisible by K
Count the number of islands in a grid where the sum of each island's values is divisible by a given integer k.
Related Patterns
Array plus Matrix
48 linked problems
State transition dynamic programming
43 linked problems
Array plus Depth-First Search
39 linked problems
Array scanning plus hash lookup
24 linked problems
Binary search over the valid answer space
14 linked problems
Greedy choice plus invariant validation
11 linked problems