# Category Archives: Matrix

## Minimum number of operations required to set all elements of a binary matrix

Given a binary matrix mat[][] consisting of 1s and 0s of dimension M * N, the task is to find the number of operations to… Read More »

## Sum of cost of all paths to reach a given cell in a Matrix

Given a matrix grid[][] and two integers M and N, the task is to find the sum of cost of all possible paths from the… Read More »

## Number of ways to paint K cells in 3 x N grid such that no P continuous columns are left unpainted

Given three integers N, P and K, the task is to find the number of ways of painting K cells of 3 x N grid… Read More »

## Count of numbers in given range L to R which are present in a Matrix

Given a matrix(mat[][]), which is sorted row and column-wise in increasing order. Two integers are given, L and R, our task is to count number… Read More »

## C program to implement Adjacency Matrix of a given Graph

Given a undirected Graph of N vertices 1 to N and M edges in form of 2D array arr[][] whose every row consists of two… Read More »

## Minimum moves taken to move coin of each cell to any one cell of Matrix

Given an odd number N which represents a grid of size N x N which is initially filled by coins, the task is to find… Read More »

## Check if it is possible to get given sum by taking one element from each row

Given a 2-D array of N rows and M columns and an integer K. The task is to find whether is it possible to take… Read More »

## Largest Square in a Binary Matrix with at most K 1s for multiple Queries

Given a binary matrix M where each element of the matrix will be 0 or 1, the task is to find the largest square that… Read More »

## Sort a 2D vector diagonally using Map Data Structure

Given a 2D vector mat[][] of integers. The task is to sort the elements of the vectors diagonally from top-left to bottom-right in increasing order.… Read More »

## Sum of all parts of a square Matrix divided by its diagonals

Given a 2D matrix arr[][] of N*N dimensions, the task is to find the sum of elements of all four parts of the matrix divided… Read More »

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

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 »

## Count of cells in a matrix whose adjacent cells’s sum is prime Number

Given a M x N matrix mat[][], the task is to count the number of cells which have the sum of its adjacent cells equal… Read More »

## 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 »