## Find the minimum cost to reach last cell of the matrix from its first cell

Given a M x N matrix where each cell has a cost associated with it, find the minimum cost to reach last cell (M-1, N-1) of the matrix from its first cell (0, 0). We can only move one unit right or one unit down from any cell. i.e. from cell (i, j), we can …

## Matrix Chain Multiplication using Dynamic Programming

Matrix chain multiplication problem: Determine the optimal parenthesization of a product of n matrices.

## Find size of largest square sub-matrix of 1’s present in given binary matrix

Given a M x N binary matrix, find the size of largest square sub-matrix of 1’s present in it.

## Find Maximum Sum Submatrix present in a given matrix

Given an M x M matrix, find maximum sum submatrix present in it.

## Find Maximum Sum Submatrix in a given matrix

Given a M x N matrix, calculate maximum sum submatrix of size k x k in a given M x N matrix in O(M*N) time. Here, 0 < k < M, N.

## Calculate sum of all elements in a sub-matrix in constant time

Given a M x N matrix and two coordinates (p, q) and (r, s) which represents top-left and bottom-right coordinates of a sub-matrix of the given matrix, calculate the sum of all elements present in the sub-matrix in O(1) time. Here, 0 < = p < r < M and 0

## Report all occurrences of an element in row wise and column wise sorted matrix in linear time

Given a M x N matrix which is row wise and column wise sorted (with all strictly increasing elements in any row or column), report all occurrences of a given element in it in linear time.

## Count negative elements present in sorted matrix in linear time

Given a M x N matrix which is row wise and column wise sorted, count number of negative elements present in it in linear time.

## Find Probability that a Person is Alive after Taking N steps on an Island

Given an island in the form of square matrix and a point inside the matrix where a person is standing. The person is allowed to move one step in any direction (right, left, top, down) on the matrix. If he steps outside the matrix, he dies. Calculate the probability that he is alive after he …

## In-place rotate matrix by 90 degrees in clock-wise direction

Given a square matrix, rotate matrix by 90 degrees in clock-wise direction. The transformation should be done in-place and in quadratic time.

## Replace all occurrences of 0 that are not surrounded by 1 in a binary matrix

Give a M x N binary matrix, replace all occurrences of 0 by 1 which are not completely surrounded by 1.

## Find all paths from first cell to last cell of a matrix

Given a M x N matrix, find all paths from first cell to last cell. We can only move down or to the right from the current cell.