# Category Archives: Backtracking

Given a Binary search tree having N nodes, the task is to find all the paths starting at the root and ending at any leaf… Read More
Given arr[] of 5 integers denoting the values of X+Y, X−Y, X*Y, X%Y and ⌊X/Y⌋  in sorted order for two non-zero integers X and Y,… Read More
Given an array Arr[] of size N, the task is to find the count of subsets of Arr[] that can be partitioned into two non-empty… Read More
Given an N*M (N + M ≤ 40)matrix mat[][], each cell has some value ranging from 0 to 1018 and an integer  K. Find the… Read More
In the COVID times, a movie theatre has to follow a Social distance rule where every two seated individuals must have at least 6 feet… Read More
Given a string str, consisting of lower case English alphabets and digits(0-9),  the task is to print all possible strings in lexicographic order that can… Read More
Given a string str, the task is to find whether it contains an additive sequence or not. A string contains an additive sequence if its… Read More
Given an integer N, the task is to print the ways to get the sum N by repeatedly throwing a dice. Input: N = 3Output: 1… Read More
Given 2 integers M and N, the task is to find the count of all the possible paths from top left to the bottom right… Read More
Given a root of binary tree and two integers startValue and destValue denoting the starting and ending node respectively. The task is to find the… Read More
Given a 2D matrix of size n*m, a source ‘s’ and a destination ‘d’, print the count of all unique paths from given ‘s’ to… Read More
Given a 2-D array mat[][], a source ‘s’ and a destination ‘d’, print all unique paths from given ‘s’ to ‘d’.  From each cell, you… Read More
Given a matrix mat[][], and the coordinates of source and destination node, the task is to find the length of the longest path from source… Read More
Given an array of integers arr[], find the subsequence with maximum sum whose elements are first decreasing, then increasing, or vice versa, The subsequence can… Read More
Given vector nums, the task is to print all the possible permutations of the given vector using backtracking  Examples: Input: nums[] = {1, 2, 3}Output:… Read More