# Find all possible combinations of decodings of a number.

Given an encoding number as explained below, we aim to print all combinations of decoding strings to that input number. The encoding number is as follows. Defining a recursion for this problem is very simple. Let us see the recursion tree for the input number. Let us now write the code for this recursion algorithm.Read More »

# Sum of digits of a number using recursion and iterative approaches.

Divide each digit from the input number by using a modulus operator (with 10), and then adding it into a total will give us the sum of its digits. Let us take this solution with an example. This problem can be solved iteratively and recursively. Let us see the code for both approaches. Recursive approachRead More »

# Check if given two binary trees are the mirrors to each other

A mirror binary tree is a tree in which the left subtree is on the right side and right subtree on the left side. Let’s see below two binary trees for better understanding. Here in the above images, both trees are mirrors to one another. The recursion formula is simple to this problem. As weRead More »

# Minimum cost to reach the end of the array using recursion and dynamic programming

Given an array of different costs(which is positive integers) of size ‘N.’ And a maximum possible jump from the current index to other index is ‘K.’ We aim to find the minimum cost to reach the end of the array. Let’s take below example to understand this problem better. In the above example, starting fromRead More »

# Longest palindromic substring length of a given string (recursion and dynamic programming approach)

A substring is a string formed based on a continuous subset of characters of another big series. Let’s see the following example. As we do in the longest palindromic subsequence length, we have a similar formula here with a small condition. The condition here is the length of substring whichever formed should be equal toRead More »

# Check given string is palindrome or not

A palindrome string is a string that reads similar from back to front. For example strings like “rotator”, “madam”, …etc. Easy way to prove a string is a palindrome or not is to reverse the string and compare it with original series, If both the strings are same then that string is palindrome string. AsRead More »

# Different methods to reverse a string

There are multiple ways to reverse a string, whereas here in this article. We are going to discuss a few such methods. First of all, let’s take an example string and see how characters in its reverse series will appear. In the above example, we have taken a string of size seven characters from “0…6”.Read More »

# Longest palindromic subsequence length of a string

Given an input string of size ‘N’ characters. We aim to find maximum length subsequence which is palindromic. A subsequence string is a sequence that is formed by another sequence by removing zero or more characters. Whereas a palindrome string is a string that can be read the same from the backward as forward. WeRead More »

# Print all subsequences of a given string (Recursive approach)

A subsequence of a sequence string is generated by removing 0 or more characters from the sequence string. Let’s take an example string “Hello” which is of size 5. The total number of subsequences are , where N is the length of the input string. To make formula for recursion, we either pick the currentRead More »

# Longest common subsequence length of given two strings

A subsequence is a sequence formed by another sequence after removal of 0 or more items from it. The order that items appear won’t change in the subsequence. In strings, a subsequence string generates by removing 0 or more characters from the parent string. A common subsequence is a subsequence generated from two string. Let’sRead More »

# Count of all subsets with given sum in an unsorted integer array

Given an array of unsorted integers of size ‘N,’ we aim to find all subsets count with sum is equivalent to a given sum. A subset array is an array in which all the items on it exists in another bigger array. Here the array is called subset to the larger array. To find theRead More »

# Find steps to solve the Tower of Hanoi problem

The Tower of Hanoi is one of the oldest mathematical puzzles from ancient times. We have three towers, in one of the towers we have “N” disks. All “N” disks are arranged in such a way that only smaller radius disks can be placed on top larger radius disks, vise-versa not allowed. Here we aimRead More »

# House thief problem (using recursion and dynamic programming)

A thief knows all gold reserves of a neighborhood that is in a single row. Thief want’s to have a plan earlier on which houses he wants to steal. To avoid a triggering alarm his condition is to avoid stealing any two houses which are right next to each other. Let’s understand this problem withRead More »

# 0/1 Knapsack problem example with recursion and dynamic programming solutions

A farmer wants to sell his farm products in the city. He has a knapsack with the capacity of “N” kgs weight, and he has products with more than ‘N’ kgs weight. He wants to fill his backpack in such a way that he gets more money after selling the products in the knapsack. HereRead More »

# Coin change problem (Find all number of combinations that formed a sum amount with given denominations)

Given a set of denominations of coins and an amount, our aim is find number of combinations in which we can arrange denominations to form our input amount. Let’s understand this better with following example. We can solve this problem using below two different approaches. Recursion Dynamic Programming. Recursion Let’s divide our problem into smallerRead More »