Skip to content

Category Archives: Backtracking

Given an array of strings, words[] of size M and a string target of size N. The task is to find the minimum number of… Read More
Given an undirected Graph consisting of N nodes in the form of an adjacency matrix graph[][] of size N*N, the task is to print all… Read More
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
Given N nodes valued by [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 nums[] of size N, the task is to print all possible distinct permutations of the array nums[] (including duplicates). Input: nums[] =… Read More