# Category Archives: Matrix

The problem is to count all the possible paths from top left to bottom right of a mXn matrix with the constraints that from each… Read More
The problem is to print all the possible paths from top left to bottom right of a mXn matrix with the constraints that from each… Read More
Given a 2D matrix, print all elements of the given matrix in diagonal order. For example, consider the following 5 X 4 input matrix.   Example:… Read More
Given a 2D array, find the maximum sum submatrix in it. For example, in the following 2D array, the maximum sum submatrix is highlighted with… Read More
Given a boolean 2D matrix, find the number of islands. A group of connected 1s forms an island. For example, the below matrix contains 5… Read More
Given an M x N matrix, transpose the matrix without auxiliary memory.It is easy to transpose matrix using an auxiliary array. If the matrix is… Read More
Given a binary matrix, print all unique rows of the given matrix.  Example:  Input: {0, 1, 0, 0, 1} {1, 0, 1, 1, 0} {0,… Read More
Given a boolean 2D array, where each row is sorted. Find the row with the maximum number of 1s.  Example:   Input matrix 0 1 1… Read More
A magic square of order n is an arrangement of n2 numbers, usually distinct integers, in a square, such that the n numbers in all… Read More
Given a partially filled 9×9 2D array ‘grid’, the goal is to assign digits (from 1 to 9) to the empty cells so that every… Read More
In a party of N people, only one person is known to everyone. Such a person may be present in the party, if yes, (s)he… Read More
Given the dimension of a sequence of matrices in an array arr[], where the dimension of the ith matrix is (arr[i-1] * arr[i]), the task… Read More
Given a cost matrix cost[][] and a position (m, n) in cost[][], write a function that returns cost of minimum cost path to reach… Read More
Given a boolean matrix mat[M][N] of size M X N, modify it such that if a matrix cell mat[i][j] is 1 (or true) then make… Read More
Given a 2D array, print it in spiral form. Examples:  Input:  {{1,    2,   3,   4},              {5,… Read More