# Category Archives: Matrix

## Traverse the matrix in Diagonally Bottum-Up fashion using Recursion

Given a matrix mat[][] of size N x N, the task is to traverse the matrix Diagonally in Bottom-up fashion using recursion. Diagonally Bottum-up Traversal:… Read More »

## Maximum neighbor element in a matrix within distance K

Given a matrix mat[][] and an integer K, the task is to find the maximum neighbor within an absolute distance of K for each element… Read More »

## Count all square sub-matrix with sum greater than the given number S

Given a matrix mat[][] and two integers K and S, the task is to count all K x K sub-matrix such that the sum of… Read More »

## Leftmost Column with atleast one 1 in a row-wise sorted binary matrix

Given a binary matrix mat[][] containing 0’s and 1’s. Each row of the matrix is sorted in the non-decreasing order, the task is to find… Read More »

## Number of ways to select equal sized subarrays from two arrays having atleast K equal pairs of elements

Given two arrays A[] and B[], and an integer K, the task is to find the number of ways to select two subarrays of the… Read More »

## Program to concatenate two given Matrices of same size

Given two matrices A and B of size M x N, the task is to concatenate them into one matrix. Concatenation of matrix: The process… Read More »

## Maximum strength in a Matrix after performing specified operations

Given a matrix of N * M containing {0, 1, #}. The task is to find the maximum value of strength based on following rules:… Read More »

## Maximum of all distances to the nearest 1 cell from any 0 cell in a Binary matrix

Given a Matrix of size N*N filled with 1‘s and 0‘s, the task is to find the maximum distance from a 0-cell to its nearest… Read More »

## Minimum number of Water to Land conversion to make two islands connected in a Grid

Given a 2D grid arr[][] of ‘W’ and ‘L’ where ‘W’ denotes water and ‘L’ denotes land, the task is to find the minimum number… Read More »

## Check if a given matrix can be converted to another given matrix by row and column exchanges

Given a matrix startMatrix and another matrix finalMatrix, the task is to check if startMatrix can be converted to finalMatrix by column exchanges and a… Read More »

## Return an array of anti-diagonals of given N*N square matrix

Given a square matrix of size N*N, return an array of its anti-diagonals. For better understanding let us look at the image given below: Examples:… Read More »

## Find the row whose product has maximum count of prime factors

Given a matrix of size N x M, the task is to print the elements of the row whose product has a maximum count of… Read More »

## Maximum size square Sub-Matrix with sum less than or equals to K

Given a Matrix arr[][] of size MxN having positive integers and a number K, the task is to find the size of largest square sub-matrix… Read More »

## Find the product of sum of two diagonals of a square Matrix

Given a square matrix mat consisting of integers of size NxN, the task is to calculate the product between the sums of its diagonal. Examples:… Read More »

## Check whether a Matrix is a Latin Square or not

Given a square matrix of size N x N, the task is to check if it is Latin square or not. A square matrix is… Read More »