Category: Matrix

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.

Find shortest distance of every cell from landmine in a Maze

Given a Maze in the form of a rectangular matrix, filled with either O, X or M, where O represents an open cell, X represents a blocked cell and M represents landmines in the maze, we need to find shortest distance of every open cell in the maze from its nearest mine.   We’re only …

Construct a Binary Tree from Ancestor Matrix

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

Find shortest route in a device to construct the given string

Given a device having left, right, top and bottom buttons and a OK button to enter a text from a virtual keypad having alphabets from A-Y arranged in a 5×5 grid as shown below. We need to find the shortest route in device to construct the given string if we start from the top-left position …