Print diagonal elements of the matrix having positive slope

Given a M x N matrix, print all its diagonal elements having positive slope.

Change all elements of row i and column j in a matrix to 0 if cell (i, j) has value 0

Give a M x N matrix consisting of only 0 or 1, change all elements of row i and column j to 0 if cell (i, j) has value 0. Do this without using any extra space for every (i, j) having value 0.

Find Shortest path from source to destination in a matrix that satisfies given constraints

Given a N x N matrix of positive integers, find shortest path from the first cell of the matrix to its last cell that satisfies given constraints.

Shift all Matrix Elements by 1 in Spiral Order

Given a M x N matrix, shift all its elements by 1 in spiral order.

Create Spiral Matrix from given Array

Given an array containing M*N elements, construct a M x N matrix from it in spiral order.

Print a spiral square matrix without using any extra space

Given a positive number N, print a N x N spiral matrix containing numbers from 1 to N x N in counter clockwise direction and without using any extra space.

Print Matrix in Spiral Order

Given a MxN matrix, print matrix in spiral order.

Count the number of islands

Given a binary matrix where 0 represents water and 1 represents land, count the number of islands in it. A island is formed by connected one’s.   For example, consider below image.    Above image highlights water in blue and land in grey in a 10 x 10 matrix. There are total five islands present in the above …

Flood Fill Algorithm

Flood fill (also known as seed fill) is an algorithm that determines the area connected to a given node in a multi-dimensional array.

Find shortest safe route in a field with sensors present

Given a rectangular field with few sensors present on it, cross it by taking the shortest safe route without activating the sensors.   The rectangular field is given in the form of M x N matrix and we need to find the shortest path from any cell in first column to any cell in the …

Find all occurrences of given string in a character matrix

Given a M x N matrix of characters, find all occurrences of a given string in the matrix. We are allowed to search the string in all eight possible directions i.e. North, West, South, East, North-East, North-West, South-East, South-West. Note that there should not be any cycles in the output path.

Shortest path in a Maze | Lee algorithm

Given a maze in the form of the binary rectangular matrix, find length of the shortest path in a maze from given source to given destination.