# Category Archives: Matrix

Given a matrix mat[][] of size M x N where mat[i][j], the task is to find the maximum possible sum by picking contiguous elements from… Read More
The below program adds two square matrices of size 4*4, we can change N for different dimensions.  Recommended: Please solve it on “PRACTICE” first, before… Read More
Given an integer matrix mat[][] of size M x N and an integer K, the task is to return the number of paths from top-left… Read More
Given a 2D binary matrix of size N * M, where 0 represents an empty space while 1 represents a wall you cannot walk through.… Read More
Given an N x N binary matrix grid, where 0 represents a sea cell and 1 represents a land cell. A move consists of walking… Read More
Given a matrix of size N * M. Every cell of the matrix contains either ‘A’ or ‘B’. Exchange is defined as swapping the characters… Read More
Given an N×N Matrix Mat[][] of N rows and N columns. There is exactly one Queen on the chessboard and the cell that is under… Read More
Given an 8 X 8 matrix of characters ‘*’ and ‘K’  as a chessboard in which K represents the position of the King and the… Read More
Given an matrix mat[][] of size N*N (N > 2) such that mat[i][j] = arr[i]*arr[j] (where arr[] is a N sized array that is not… Read More
Given a character matrix consisting of O’s and X’s, find the number of submatrices containing only ‘X’ and surrounded by ‘O’ from all sides.  Examples:… Read More
Given a matrix of size N*M, the task is to find the product of all possible pairs of (i, j) where i and j are… Read More
Given an undirected graph with V vertices in the form of an adjacency matrix, the weight of any two edges cannot be the same. For… Read More
Given a matrix Mat of size N x M, the task is to find all the pairs of rows and columns where the sum of… Read More
Given an N×N matrix mat[][] and an integer K, the task is to search K in mat[][] and if found return its indices. Examples: Input:… Read More
Given a matrix of size N * N containing only 0s and 1s, where 0 represents white and 1 represents black. The task is to… Read More