Tag Archives: BFS

Given an integer N which denotes the number of slots, and an array arr[] consisting of K integers in the range [1, N] repreand. Each… Read More
Given a Binary tree consisting of N nodes with values in the range [1, N], the task is to find the distance from the root… Read More
Given two arrays arr[] and jumps[] consisting of N positive integers, the task for each array element arr[i] is to find the minimum number of… Read More
Given a N-ary Tree consisting of nodes valued in the range [0, N – 1] and an array arr[] where each node i is associated… Read More
Given a graph G consisting of nodes valued [0, N – 1], a source S, and an array Edges[][3] of type {u, v, w} that… Read More
Given an N-ary Tree consisting of nodes valued [1, N] and an array value[], where each node i is associated with value[i], the task is… Read More
Given an N-ary tree, the task is to find the maximum width of the given tree. The maximum width of a tree is the maximum… Read More
Given an N-ary Tree having N nodes with positive and negative values and (N – 1) edges, the task is to find the maximum absolute… Read More
Given an N-ary Tree rooted at 1, the task is to find the difference between the sum of nodes at the odd level and the… Read More
Given a matrix arr[][] of dimensions N * M, having elements 0, 1, and 2. There is only one cell with value 1 present in… Read More
Given two strings start and target(both of the same length) and a list of strings str[], the task is to print all possible smallest sequences… Read More
Given an undirected graph G, with V vertices and E edges, the task is to check whether the graph is 2-edge connected or not. A… Read More
Given a Directed Acyclic Graph having V vertices and E edges, where each edge {U, V} represents the Jobs U and V such that Job… Read More
Given a binary matrix mat[][] of dimensions NxM such that 1 denotes the island and 0 denotes the water. The task is to find the… Read More
Given two integers R and C, denoting the number of rows and columns in a matrix, and two integers X and Y, the task is… Read More