# Category Archives: Dynamic Programming

## Ways of transforming one string to other by removing 0 or more charactersJuly 27, 2017

Given two sequences A, B, find out number of unique ways in sequence A, to form a subsequence of A that is identical to the… Read More »

## Find length of longest subsequence of one string which is substring of another stringJuly 9, 2017

Given two string X and Y. The task is to find the length of longest subsequence of string X which is substring in sequence Y.… Read More »

## Non-decreasing subsequence of size k with minimum sumJuly 5, 2017

Given a sequence of n integers, you have to find out the non-decreasing subsequence of length k with minimum sum. If no sequence exists output… Read More »

## Paper Cut into Minimum Number of Squares | Set 2

Given a paper of size A x B. Task is to cut the paper into squares of any size. Find the minimum number of squares… Read More »

## Count of Palindromic substrings in an Index rangeJuly 4, 2017

Given a string str of small alphabetic characters other than this we will be given many substrings of this string in form of index tuples.… Read More »

## Find maximum possible stolen value from housesJune 27, 2017

There are n houses build in a line, each of which contains some value in it. A thief is going to steal the maximal value… Read More »

## Number of n-digits non-decreasing integers

Given an integer n > 0, which denotes the number of digits, the task to find total number of n-digit positive integers which are non-decreasing… Read More »

## Painting Fence AlgorithmJune 24, 2017

Given a fence with n posts and k colors, find out the number of ways of painting the fence such that at most 2 adjacent… Read More »

## Bitmasking and Dynamic Programming | Set-2 (TSP)June 23, 2017

In this post, we will be using our knowledge of dynamic programming and Bitmasking technique to solve one of the famous NP-hard problem “Travelling Salesman… Read More »

## Find the Longest Increasing Subsequence in Circular mannerJune 22, 2017

Given an array, the task is to find to LIS (Longest Increasing Subsequence) in a circular way. Examples: Input : arr[] = {5, 4, 3,… Read More »

## Choose maximum weight with given weight and value ratioJune 19, 2017

Given weights and values of n items and a value k. We need to choose a subset of these items in such a way that… Read More »

## Count Balanced Binary Trees of Height hJune 17, 2017

Given a height h, count and return the maximum number of balanced binary trees possible with height h. A balanced binary tree is one in… Read More »

## Minimum time to write characters using insert, delete and copy operationJune 14, 2017

We need to write N same characters on a screen and each time we can insert a character, delete the last character and copy and… Read More »

## Counts paths from a point to reach OriginJune 13, 2017

You are standing on a point (n, m) and you want to go to origin (0, 0) by taking steps either left or down i.e.… Read More »

## Pyramid form (increasing then decreasing) consecutive array using reduce operationsJune 12, 2017

We have N (where N > 2) stones of various heights laid out in a row. Task is to make a pyramid from given array… Read More »