# Category Archives: Matrix

## Minimum cost to reach from the top-left to the bottom-right corner of a matrix

Given an N * M matrix mat[][] consisting of lower case characters, the task is to find the minimum cost to reach from the cell… Read More »

## Print all possible paths from the first row to the last row in a 2D array

Given a 2D array of characters with M rows and N columns. The task is to print all the possible paths from top (first row)… Read More »

A graph is a presentation of a set of entities where some pairs of entities are linked by a connection. Interconnected entities are represented by… Read More »

## Expected number of moves to reach the end of a board | Matrix Exponentiation

Given a linear board of length N numbered from 1 to N, the task is to find the expected number of moves required to reach… Read More »

## Expected number of moves to reach the end of a board | Dynamic programming

Given a linear board of length N numbered from 1 to N, the task is to find the expected number of moves required to reach… Read More »

## Find the minimum difference path from (0, 0) to (N-1, M-1)

Given two 2D arrays b[][] and c[][] of N rows and M columns. The task is to minimise the absolute difference of the sum of… Read More »

## Number of cells in a matrix that satisfy the given condition

Given an N * N grid consisting of empty cells (denoted by ‘1’) and obstacles (denoted by ‘0’), the task is to find the number… Read More »

## Minimum steps to get 1 at the center of a binary matrix

Given an N * N matrix where N is odd with all 0 values except for a single cell which has the value 1. The… Read More »

## Find N in the given matrix that follows a pattern

Given an infinite matrix filled with the natural numbers as shown below: 1 2 4 7 . . . 3 5 8 . . .… Read More »

## Minimum cells to be flipped to get a 2*2 submatrix with equal elements

Given a matrix of size M * N, the task is to find the count of the minimum number of cells that must be flipped… Read More »

## Maximize sum by choosing elements from different section of a matrix

Given a matrix of N rows and M columns. It is given that M is a multiple of 3. The columns are divided into 3… Read More »

## Convert given Matrix into sorted Spiral Matrix

Given a matrix, the task is to convert the given Matrix into sorted Spiral Matrix. Examples: Input: y[][] = { { 2, 5, 12 },… Read More »

## Form a Spiral Matrix from the given Array

Given an array, the task is to form a spiral matrix Examples: Input: arr[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9,… Read More »

## Number of ways to reach (X, Y) in a matrix starting from the origin

Given two integers X and Y. The task is to find the number of ways to reach (X, Y) in a matrix starting from the… Read More »

## Find the weight at (Xi, Yi) after M operations in a Matrix

Given n x n points on cartesian plane, the task is to find the weight at (xi, yj) after m operation. xi, yj, w denotes… Read More »