# Category: Backtracking

## Find the path between given vertices in a directed graph

Given a directed graph and two vertices (say source and destination vertex), determine if the destination vertex is reachable from the source vertex or not. If the path exists from the source vertex to the destination vertex, print it.

## Find ways to calculate a target from elements of specified array

Write a program to count number of ways to calculate a target number from elements of specified array by using only addition and subtraction operator. The use of any other operator is forbidden.

## Print all shortest routes in a rectangular grid

Given a M x N rectangular grid, print all shortest routes in the grid that start at the first cell (0,0) and end at the last cell (N-1,M-1). We can move down or right or diagonally (down-right) but not up or left.

## K-Partition Problem | Printing all Partitions

In k-partition problem, we need to partition an array of positive integers into k disjoint subsets that all have equal sum and they completely covers the set.

## Determine if a pattern matches with a string or not

Given a string and a pattern, determine if the pattern matches with the string or not. The solution should not use any regex.

## Find minimum number possible by doing at-most K swaps

Given a positive integer, find minimum number possible by doing at-most K swap operations upon its digits.

## All combinations of elements satisfying given constraints

Given a positive number N, find all combinations of 2*N elements such that every element from 1 to N appears exactly twice and distance between its two appearances is exactly equal to value of the element.

## Find all permutations of a string in C++ (Using Backtracking and STL)

In this post, we will see how to find all permutations of a string containing all distinct characters in C++.

## Find all binary strings that can be formed from given wildcard pattern

Given a binary pattern that contains ‘?’ wildcard character at few positions, find all possible combinations of binary strings that can be formed by replacing the wildcard character by either 0 or 1.

## Print all k-colorable configurations of the graph (Vertex coloring of graph)

Given a graph, find if it is k-colorable or not and print all possible configuration of assignment of colors to its vertices.

## Print all Hamiltonian path present in a graph

Given an undirected graph, print all Hamiltonian paths present in it. Hamiltonian path is a path in an undirected or directed graph that visits each vertex exactly once.

## Find total number of unique paths in a maze from source to destination

Find the total number of unique paths which the robot can take in a given maze to reach the destination from given source.