# Category Archives: Matrix

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

## Count of columns with odd number of 1s

Given an N * M 2D binary matrix, the task is to find the count of columns having odd number of 1s. Examples: Input: mat[][]… Read More »

## Program to print the Diagonals of a Matrix

Given a 2D square matrix, print the Principal and Secondary diagonals. Examples : Input: 4 1 2 3 4 4 3 2 1 7 8… Read More »

## Finding the converging element of the diagonals in a square matrix

Given a square matrix, the task is to find the element of the matrix where the right and the left diagonal of this square matrix… Read More »

## Sum of the count of number of adjacent squares in an M X N grid

Given an M × N matrix. The task is to count the number of adjacent cells and calculate their sum. Two cells are said to… Read More »