Category Archives: Backtracking

Given a matrix mat[][] of size N x N, the task is to traverse the matrix Diagonally in Bottom-up fashion using recursion.Diagonally Bottom-up Traversal:  Traverse… Read More
Given a partially filled 9×9 matrix, digits (from 1 to 9) must be assigned to the empty cells so that every row, column, and submatrix… Read More
Trie is an efficient information retrieval data structure. Using Trie, search complexities can be brought to an optimal limit. Given an array of strings. The task… Read More
Given an undirected graph, a source vertex ‘s’ and a destination vertex ‘d’, the task is to count total paths from given ‘s’ to ‘d’.… Read More
Given an integer N, find the smallest N digit number such that the sum of the square of digits (in decimal representation) of the number… Read More
Given a 2D matrix, the task is to convert it into a doubly-linked list with four pointers that are next, previous, up, and down, each… Read More
Given an array arr of size N containing some integers from the range [1, N] and -1 in the remaining indices, the task is to… Read More
Given a Binary Tree, the task is to count the number of Exponential paths in the given Binary Tree.   Exponential Path is a path where… Read More
Given an undirected connected graph and two vertices A and B, the task is to find the number of pairs of vertices {X, Y} such… Read More
Given a string S, the task is to find the length longest sub-string which is a palindrome Examples: Input: S = “aaaabbaa” Output: 6 Explanation:… Read More
Given a binary tree, the task is to print all the palindromic paths of this binary tree. Palindromic path: Path in which concatenation of data… Read More
Given coordinates of a source point (srcx, srcy) and a destination point (dstx, dsty), the task is to determine the possible path to reach the… Read More
Given a directed graph with V vertices and E edges without self-loops and multiple edges, the task is to find the minimum number of colors… Read More
Given a Binary Tree, the task is to count the number of even paths in the given Binary Tree. Even Path is a path where… Read More
Given a binary tree, the task is to traverse this binary tree from the middle to the up-down order. In Middle to up-down order traversal, the… Read More