# Category: Matrix

## Young Tableau | Insert, Search, Extract-Min, Delete, Replace

A M x N Young tableau is an M x N matrix such that the entries of each row are in sorted order from left to right and the entries of each column are in sorted order from top to bottom. Some of the entries of a Young tableau may be infinity, which indicates an …

## Find the largest square sub-matrix which is surrounded by all 1’s

Given a binary matrix, find the largest square sub-matrix which is surrounded by all 1’s.

## Find index of the row containing maximum number of 1’s in a binary matrix

Given a binary M x N row-wise sorted matrix, find a row which contains maximum number of 1 in linear time.

## Find all common elements present in every row of given matrix

Given a M x N matrix, find all common elements present in every row.

## Collect maximum value of coins in a matrix

Given a M x N matrix where each cell contains a coin of some denomination, collect maximum value of coins by traversing the grid. The first traversal starts from the top-left corner of the matrix and end at the bottom-left corner and the second traversal starts from the top-right corner and end at the bottom-right …

## Count all paths in a matrix from first cell to last cell

Given a M x N rectangular grid, efficiently count all paths starting from the first cell (0,0) to the last cell (N-1,M-1) in the grid. We can either move down, or move towards right from a cell.

## Print all shortest routes in a rectangular grid

Given a M x N rectangular grid, print all shortest routes in the grid that start at the first cell (0,0) and end at the last cell (N-1,M-1). We can move down or right or diagonally (down-right) but not up or left.

## Find length of longest path in the matrix with consecutive characters

Given a M x N matrix of characters, find the length of longest path in the matrix starting from a given character. All characters in the longest path should be increasing and consecutive to each other in alphabetical order.

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

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

## Construct an Ancestor Matrix from a Binary Tree

Given a binary tree whose nodes are labelled from 0 to n-1, construct an ancestor matrix from it. An ancestor matrix is a boolean matrix, whose cell (i, j) is true if i is ancestor of j in the binary tree.

## Fill Binary Matrix with Alternating Rectangles of 0 and 1

Given a M x N binary matrix, fill it with alternating rectangles of 0 and 1.

## Maximum Length Snake Sequence

Given a square matrix, print maximum length snake sequence in it. A Snake sequence is defined as a sequence of numbers where each new number, which can only be located to the right or down of the current number, is either plus or minus one.