## Minimum edges to be added in a directed graph so that any node can be reachable from a given node

Given a directed graph and a node X. The task is to find the minimum number of edges that must be added to the graph… Read More »

## DP on Trees | Set-3 ( Diameter of N-ary Tree )

Given an N-ary tree T of N nodes, the task is to calculate the longest path between any two nodes(also known as the diameter of… Read More »

## Count the number of nodes at a given level in a tree using DFS

Given an integer l and a tree represented as an undirected graph rooted at vertex 0. The task is to print the number of nodes… Read More »

## Minimum number of edges between two vertices of a graph using DFS

Given an undirected graph G(V, E) with N vertices and M edges. We need to find the minimum number of edges between a given pair… Read More »

## Unique paths covering every non-obstacle block exactly once in a grid

Given a grid grid[][] with 4 types of blocks: 1 represents the starting block. There is exactly one starting block. 2 represents the ending block.… Read More »

## Printing pre and post visited times in DFS of a graph

Depth First Search (DFS) marks all the vertices of a graph as visited. So for making DFS useful, some additional information can also be stored.… Read More »

## Level with maximum number of nodes using DFS in a N-ary tree

Given a N-ary tree, the task is to print the level with the maximum number of nodes. Examples: Input : For example, consider the following… Read More »

## Sum of all odd nodes in the path connecting two given nodes

Given a binary tree and two nodes of that binary tree. Find the sum of all nodes with odd values in the path connecting the… Read More »

## Print levels with odd number of nodes and even number of nodes

Given an N-ary tree, print all the levels with odd and even number of nodes in it. Examples: For example consider the following tree 1… Read More »

## Find whether it is possible to finish all tasks or not from given dependencies

There are a total of n tasks you have to pick, labeled from 0 to n-1. Some tasks may have prerequisites, for example to pick… Read More »

## Find the ordering of tasks from given dependencies

There are a total of n tasks you have to pick, labeled from 0 to n-1. Some tasks may have prerequisites tasks, for example to… Read More »

## De Bruijn sequence | Set 1

Given an integer n and a set of characters A of size k, find a string S such that every possible string on A of… Read More »

## Minimum time to return array to its original state after given modifications

Given two arrays of integers arr and P such that after a cycle an element arr[i] will be at location arr[P[i]]. The task is to… Read More »

## Find maximum path length in a binary matrix

Given a square matrix mat every element of which is either 0 or 1. A value 1 means connected and 0 means not connected. The… Read More »

## Maximum number of edges among all connected components of an undirected graph

Given integers ‘N’ and ‘K’ where, N is the number of vertices of an undirected graph and ‘K’ denotes the number of edges in the… Read More »