## Print n x n spiral matrix using O(1) extra space

Given a number n, print a n x n spiral matrix (of numbers from 1 to n x n) in clockwise direction using O(1) space.… Read More »

- Sum of all Submatrices of a Given Matrix
- A variation of Rat in a Maze : multiple steps or jumps allowed
- Find sub-matrix with the given sum
- Search element in a Spirally sorted Matrix
- Minimum distance to the corner of a grid from source
- Unique paths covering every non-obstacle block exactly once in a grid
- Count number of ways to reach a given score in a Matrix
- Maximum sum path in a matrix from top to bottom and back
- Sum of bitwise AND of all submatrices
- Find the sum of the diagonal elements of the given N X N spiral matrix
- Minimum steps required to reach the end of a matrix | Set 2
- Sum of Bitwise-OR of all Submatrices
- Minimum operations of given type to make all elements of a matrix equal
- XOR of XORs of all sub-matrices
- Find minimum steps required to reach the end of a matrix | Set - 1
- Count the total number of squares that can be visited by Bishop in one move
- Minimum time required to rot all oranges | Dynamic Programming
- How to read a Matrix from user in Java?
- Number of submatrices with OR value 1
- Find minimum steps required to reach the end of a matrix | Set 2
- Number of submatrices with all 1s
- Rat in a Maze Problem when movement in all possible directions is allowed
- Maths behind number of paths in matrix problem
- Check if the robot is within the bounds of the grid after given moves
- XOR of a submatrix queries
- Count possible moves in the given direction in a grid
- Element in a matrix starting from which anti-clockwise traversal ends at the last element
- Find maximum path sum in a 2D matrix when exactly two left moves are allowed
- Find row with maximum and minimum number of zeroes in given Matrix
- Find the original matrix when largest element in a row and a column are given

Given a number n, print a n x n spiral matrix (of numbers from 1 to n x n) in clockwise direction using O(1) space.… Read More »

We have a square matrix whose size is continuously expanding by factor of 2. Given a sequence present in the matrix at position (i, j)… Read More »

Given an square matrix, turn it by 90 degrees in anti-clockwise direction without using any extra space. Examples : Input 1 2 3 4 5… Read More »

Given a MxN matrix where each element can either be 0 or 1. We need to find the shortest path between a given source cell… Read More »

Given a matrix of characters and a pattern, find the orientation of pattern in the matrix. In other words, find if pattern appears in matrix… Read More »

Given an n x n matrix mat[n][n] of integers, find the maximum value of mat(c, d) – mat(a, b) over all choices of indexes such… Read More »

Given an N x N matrix, find a k x k submatrix where k = 1, such that sum of all the elements in submatrix… Read More »

Given an m x n matrix, find all common elements present in all rows in O(mn) time and one traversal of matrix. Example: Input: mat[4][5]… Read More »

Write a code to convert a matrix in specific way without using extra space. Input: 1 2 3 4 5 6 7 8 9 Output:… Read More »

Given an ancestor matrix mat[n][n] where Ancestor matrix is defined as below. mat[i][j] = 1 if i is ancestor of j mat[i][j] = 0, otherwise… Read More »

Given a Binary Tree where all values are from 0 to n-1. Construct an ancestor matrix mat[n][n]. Ancestor matrix is defined as below. mat[i][j] =… Read More »

Find the number of negative numbers in a column-wise / row-wise sorted matrix M[][]. Suppose M has n rows and m columns. Example: Input: M… Read More »

Given a binary matrix, find the maximum size rectangle binary-sub-matrix with all 1’s. Example: Input : 0 1 1 0 1 1 1 1 1… Read More »

This is one of the most used techniques in competitive programming. Let us first consider below simple question. What is the minimum time complexity to… Read More »

Given a matrix of size M x N, there are large number of queries to find submatrix sums. Inputs to queries are left top and… Read More »