Given a matrix of size (n*m) and a point ‘p‘ (x, y). The matrix is given in the form of 0‘s and 1‘s. In one… Read More
Tag Archives: DFS
Given positive integers N and M where N represents Vertices and M represents Edges. The power of each vertex is specified in an array arr[]… Read More
Given an undirected graph, with n nodes numbered from 0 to n-1. Given a 2D integer array of edges where edges[i]= [ai, bi] denotes that… Read More
Given a binary tree with positive values of nodes, find the minimum number of nodes that need to be removed to transform it into a… Read More
Given a binary tree and a target sum, determine whether there exists a root-to-leaf path in the tree such that the sum of the values… Read More
Given N sticks with two sides Left and Right (represented by 0 and 1). Given 2d array, A[][4] of size M representing operations that have… Read More
Given an undirected graph with N vertices and M edges. The task for this problem is to check whether each connected component of the given… Read More
A directed graph of V vertices and E edges is given in the form of an adjacency list adj. Each node of the graph is… Read More
Given a graph in the form of an edge list and a directed graph, return all the ancestors of the nodes in any order. An… Read More
Given an array arr[] of size N and an integer k. Return True, otherwise False, if there’s any way to reach the last element of… Read More
Given a tree with N vertices from 0 to N-1 (0th node is root) and val[] where val[i] denotes the value of the ith vertex.… Read More
Given a grid of dimension M * N where each cell varies from 1 to 6 and each of the values present in the cell… Read More
Given a tree consisting of N nodes where the value of each node is the negative of its node number (i.e., 1st node has a… Read More
Given a grid of size N * M consisting of O’s and X’s. The task is to find the number of ‘X’ total shapes. Note:… Read More
Given a set of 109 nodes. There are N bidirectional connections, and ith connection connects the Aith and Bith nodes. Starting from the first node,… Read More