Given a string S of size N, consisting of digits [0 – 9] and character ‘.’, the task is to print the string that can… Read More

# Category Archives: Backtracking

Given N nodes valued from [1, N], an array arr[] consisting of N positive integers such that the ith node ( 1-based indexing ) has… Read More

Given an array arr[] consisting of N strings, an array letter[] consisting of M lowercase characters, and an array score[] such that score[i] is the… Read More

Given a positive integer N representing the number of disks in the Tower of Hanoi, the task is to solve the Tower of Hanoi puzzle… Read More

Given a matrix grid[][] of dimensions M * N, three integers X, Y, and K, the task is to check if there exists any path… Read More

Given a binary matrix mat[][] of dimensions of N * M and pairs of integers src and dest representing source and destination cells respectively, the… Read More

Given two integers N and K, the task is to find all valid combinations of K numbers that adds up to N based on the… Read More

Given a 2D array arr[][] of dimensions N*M, representing a minesweeper matrix, where each cell contains an integer from the range [0, 9], representing the… Read More

Given an array arr[] consisting of N integers, the task is to find the sum of all subsets from an array, whose sum is a… Read More

Given an array arr[] of size N, representing the number of balls of each of N distinct colors, the task is to find the probability… Read More

Given an array arr[] of size N, the task is to count the number of arrays having at least K elements greater than the XOR… Read More

Given a positive integer N, the task is to construct the lexicographically largest array of size (2 * N – 1) comprising of first N… Read More

Given an array nums[] of size N, the task is to print all possible distinct permutations of the array nums[] (including duplicates). Input: nums[] =… Read More

Given a Binary Tree, the task is to remove all the subtrees that do not contain any odd valued node. Print the Levelorder Traversal of… Read More

Given an array arr[] consisting of N integers and an integer K, the task is to find the minimum sum of incompatibilities of K subsets… Read More