Skip to content

Tag Archives: DFS

Given N tanks connected like a tree, the connections between them in an array Edge[][], and the capacity of each tank in the array cap[],… Read More
Given a directed graph with N nodes and M edges in array V[], the task is to find the number of nodes that are accessible… Read More
Given an undirected tree with N nodes numbered from 1 to N and an array A[] where A[i] denotes the value assigned to (i+1)th node.… Read More
Given two integers N and M, the task is to generate any N * M sized maze containing only 0 (representing a wall) and 1… Read More
Given a tree with N vertices and N-1 edges represented by a 2D array edges[], the task is to find the minimum value among the… Read More
Given a binary tree, a target node and a positive integer K on it,  the task is to find the sum of all nodes within… Read More
Given a tree of N vertices, the task is to find the number of pairs of vertices such that the distance between them is even… Read More
Given, a binary tree, the task is to convert this tree using minimum number of increment-decrement operations into a tree which satisfies the following conditions:… Read More
Given a binary tree, the task is to: Print all the leaf nodes and then delete them all.  Repeat this process till the tree becomes… Read More
Given a tree of having N nodes rooted at node 0, and an array val[] denoting the value at each node, the task is to… Read More
Given a matrix of size N * M and Q queries, the task is to find how many different regions will be there, after performing… Read More
Given a binary tree of N nodes, the task is to find the maximum product of the elements of any path in the binary tree. … Read More
Given a tree with N nodes, numbered from 0 to N – 1, the task is to find the minimum number of deletion of edges,… Read More
Given a string str and K pair of characters, the task is to check if string str can be made Palindrome, by replacing one character… 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

Start Your Coding Journey Now!