# Category Archives: Dynamic Programming

## Tile Stacking Problem

A stable tower of height n is a tower consisting of exactly n tiles of unit height stacked vertically in such a way, that no… Read More »

## Counting pairs when a person can form pair with at most one

Consider a coding competition on geeksforgeeks practice. Now their are n distinct participants taking part in the competition. A single participant can make pair with… Read More »

## Count of strings where adjacent characters are of difference one

iven a number n, count number of strings of length n such that every string has adjacent characters with difference between ASCII values as 1.… Read More »

## Longest Repeated Subsequence

Given a string, print the longest repeating subseequence such that the two subsequence don’t have same string character at same position, i.e., any i’th character… Read More »

## Sub-tree with minimum color difference in a 2-coloured tree

A tree with N nodes and N-1 edges is given with 2 different colours for its nodes. Find the sub-tree with minimum colour difference i.e.… Read More »

## Longest alternating sub-array starting from every index in a Binary Array

Given an array containing only 0s and 1s. For each index ‘i‘(0 index), find length of the longest alternating sub-array starting from ‘i‘ to ‘j‘… Read More »

## Longest Common Subsequence with at most k changes allowed

Given two sequence P and Q of numbers. The task is to find Longest Common Subsequence of two sequence if we are allowed to change… Read More »

## Count all subsequences having product less than K

Given a non negative array, find the number of subsequences having product smaller than K. Examples: Input : [1, 2, 3, 4] k = 10… Read More »

## Number of ways to arrange N items under given constraints

We are given N items which are of total K different colors. Items of the same color are indistinguishable and colors can be numbered from… Read More »

## Longest Increasing Path in Matrix

Given a matrix of N rows and M columns. From m[i][j], we can move to m[i+1][j], if m[i+1][j] > m[i][j], or can move to m[i][j+1]… Read More »

## Minimum cells required to reach destination with jumps equal to cell values

Given a m x n matrix mat[][] containing positive integers. The problem is to reach to the cell (m-1, n-1) from the cell (0, 0)… Read More »

## Maximum points from top left of matrix to bottom right and return back

Given a matrix of size N X M consisting of ‘#’, ‘.’ and ‘*’. ‘#’ means blocked path, ‘.’ means walkable path and ‘*’ means… Read More »

## Find longest bitonic sequence such that increasing and decreasing parts are from two different arrays

We are given two arrays, we need to find the longest possible bitonic sequence such that increasing part must be from first array and should… Read More »

## Largest area rectangular sub-matrix with equal number of 1’s and 0’s

Given a binary matrix. The problem is to find the largest area rectangular sub-matrix with equal number of 1’s and 0’s. Examples: Input : mat[][]… Read More »

## Value of continuous floor function : F(x) = F(floor(x/2)) + x

Given an array of positive integers. For every element x of array, we need to find the value of continuous floor function defined as F(x)… Read More »