Given two integers N and X, the task is to convert 1 to N using minimum operations of any of the following operations: Change a… Read More

# Tag Archives: BFS

Geek is in a maze of size N * M. Each cell in the maze is made of either ‘.’ or ‘#’. An empty cell… Read More

Given a connected acyclic graph with N nodes numbered from 1 to N and N-1 edges, find out the pair of nodes that are at… Read More

Given a grid[][] containing 0s and 1s, where ‘0’ represents water and ‘1’ represents land. Given that an island is a group of land (1s)… Read More

Given a Grid of size NxM, and two integers X and Y, the task is to count the minimum number of rows between the row… Read More

There is an N x M rectangular island that borders both the Pacific Ocean and the Atlantic Ocean. The Pacific Ocean touches the island’s left… Read More

Given a 2D grid arr[][] of ‘W’ and ‘L’ where ‘W’ denotes water and ‘L’ denotes land, the task is to find the minimum number… Read More

Given a perfect binary tree consisting of N nodes, the task is to check if the number formed by the nodes in any level of… Read More

Given a graph G(V, E), divide it into two sets such that no two vertices in a set are connected directly. If not possible print… Read More

Given a numeric string target of length N and a set of numeric strings blocked, each of length N, the task is to find the… Read More

Given a 2D grid, each cell is either a zombie 1 or human 0. Zombies can turn adjacent horizont or vertical (up/down/left/right) human beings into… Read More

Given a string s, the task is to find the lexicographically smallest string of minimum characters that do not exist as a substring in S.… Read More

Given a number N, and some operations that can be performed, the task is to find the minimum number of moves to convert N to… Read More

Given a 2-D array matrix[][] of size ROW * COL and an integer K, where each cell matrix[i][j] is either 0 (empty) or 1 (obstacle).… Read More