In this post, we have listed out commonly asked interview questions that use matrix data structure:
- Print matrix in spiral orderMedium
- Create a spiral matrix from a given arrayMedium
- Shift all matrix elements by 1 in spiral orderMedium
- Change all elements of row
iand columnjin a matrix to 0 if cell(i, j)is 0Medium - Print diagonal elements of a matrix having a positive slopeMedium
- Replace all occurrences of 0 that are not surrounded by 1 in a binary matrixMedium
- In-place rotate matrix by 90 degrees in a clockwise directionEasy
- Count negative elements present in the sorted matrix in linear timeEasy
- Report all occurrences of an element in a row-wise and column-wise sorted matrix in linear timeMedium
- Check if a matrix is a Toeplitz or notEasy
- In-place rotate matrix by 180 degreesMedium
- Fill binary matrix with alternating rectangles of 0 and 1Medium
- Find all common elements present in each row of a matrixMedium
- Find common elements present in all rows of a matrixMedium
- Find the index of a row containing the maximum number of 1’s in a binary matrixHard
- Find the largest square submatrix which is surrounded by all 1’sMedium
- Print a spiral square matrix without using any extra spaceHard
- Young Tableau | Insert, Search, Extract-Min, Delete, ReplaceHard
- Replace all occurrences of 0 that are surrounded by 1 in a binary matrixMedium
- Find the area of the largest rectangle of 1’s in a binary matrixHard
- Find maximum value of
M[c][d] – M[a][b]over all choices of indexesMedium - Sort an array using Young tableauHard
- Print all possible solutions to N–Queens problemHard
- Print all possible Knight’s tours on a chessboardHard
- Find the shortest path in a mazeMedium
- Find the longest possible route in a matrixMedium
- Find the path from source to destination in a matrix that satisfies given constraintsMedium
- Find the total number of unique paths in a maze from source to destinationMedium
- Magnet PuzzleHard
- Find all paths from the first cell to the last cell of a matrixMedium
- Print all shortest routes in a rectangular gridMedium
- Find the shortest route in a device to construct a given stringMedium
- Find all occurrences of the given string in a character matrixHard
- Construct an ancestor matrix from a binary treeEasy
- Construct a binary tree from an ancestor matrixHard
- Find the size of the largest square submatrix of 1’s present in a binary matrixMedium
- Matrix Chain Multiplication using Dynamic ProgrammingHard
- Find minimum cost to reach the last cell of a matrix from its first cellMedium
- Find the longest sequence formed by adjacent numbers in the matrixMedium
- Count the number of paths in a matrix with a given cost to reach the destination cellMedium
- Collect maximum points in a matrix by satisfying given constraintsHard
- Find the number of ways to fill an
N × 4matrix with1 × 4tilesMedium - Ways to reach the bottom-right corner of a matrix with exactly
kturns allowedHard - Calculate the minimum cost to reach the destination city from the source cityMedium
- Find the probability that a person is alive after taking
nsteps on an islandMedium - Maximum Length Snake SequenceMedium
- Calculate the size of the largest plus of 1’s in a binary matrixHard
- Count all paths in a matrix from the first cell to the last cellEasy
- Calculate the sum of all elements in a submatrix in constant timeMedium
- Find maximum sum
K × Ksubmatrix in a givenM × NmatrixHard - Find maximum sum submatrix present in a matrixMedium
- Find the length of the longest path in a matrix with consecutive charactersMedium
- Collect maximum value of coins in a matrixHard
- Transitive closure of a graphEasy
- All-Pairs Shortest Paths – Floyd Warshall AlgorithmEasy
- Determine a negative-weight cycle in a graphMedium
- Merge
Msorted lists each containingNelementsHard - Chess Knight Problem | Find the shortest path from source to destinationHard
- Shortest path in a maze – Lee AlgorithmMedium
- Find the shortest safe route in a field with sensors presentHard
- Flood Fill AlgorithmMedium
- Count number of islandsMedium
- Find the shortest path from source to destination in a matrix that satisfies given constraintsHard
- Find minimum passes required to convert all negative values in a matrixHard
- Find the shortest distance of every cell from a landmine inside a mazeHard
- Find duplicate rows in a binary matrixMedium
- Generate a list of possible words from a character matrixHard
Thanks for reading.
To share your code in the comments, please use our online compiler that supports C, C++, Java, Python, JavaScript, C#, PHP, and many more popular programming languages.
Like us? Refer us to your friends and support our growth. Happy coding :)