# Category Archives: Dynamic Programming

## Smallest length string with repeated replacement of two distinct adjacentApril 25, 2017

Given a string of any combination of three letters ‘a’, ‘b’, and ‘c’, find length of the smallest string that can be obtained by applying… Read More »

## Top 20 Dynamic Programming Interview QuestionsApril 22, 2017

Dynamic Programming is an algorithmic paradigm that solves a given complex problem by breaking it into subproblems and stores the results of subproblems to avoid… Read More »

## Digit DP | IntroductionApril 21, 2017

Prerequisite : How to solve a Dynamic Programming Problem ? There are many types of problems that ask to count the number of integers ‘x‘… Read More »

## Subset with sum divisible by mApril 16, 2017

Given a set of non-negative distinct integers, and a value m, determine if there is a subset of the given set with sum divisible by… Read More »

## Maximum sum of a path in a Right Number Triangle

Given a right triangle of numbers, find the largest of the sum of numbers that appear on the paths starting from the top towards the… Read More »

## Largest sum Zigzag sequence in a matrix

Given a matrix of size n x n, find sum of the Zigzag sequence with the largest sum. A zigzag sequence starts from the top… Read More »

## Perfect Sum Problem (Print all subsets with given sum)April 15, 2017

Given an array of integers and a sum, the task is to print all subsets of given array with sum equal to given sum. Examples:… Read More »

## Tabulation vs MemoizatationApril 13, 2017

Prerequisite – Dynamic Programming, How to solve Dynamic Programming problems? There are following two different ways to store the values so that the values of… Read More »

## How to solve a Dynamic Programming Problem ?April 12, 2017

Dynamic Programming (DP) is a technique that solves some particular type of problems in Polynomial Time. Dynamic Programming solutions are faster than exponential brute method… Read More »

## Find number of endless pointsApril 11, 2017

Given a binary N x N matrix, we need to find the total number of matrix positions from which there is an endless path. Any… Read More »

## Count ways to increase LCS length of two strings by oneApril 3, 2017

Given two strings of lower alphabet characters, we need to find the number of ways to insert a character in the first string such that… Read More »

## Number of subsequences of the form a^i b^j c^kMarch 27, 2017

Given a string, count number of subsequences of the form aibjck, i.e., it consists of i ’a’ characters, followed by j ’b’ characters, followed by… Read More »

## Sum of all substrings of a string representing a number | Set 1March 26, 2017

Given a integer represented as a string, we need to get the sum of all possible substrings of this string. Examples: Input : num =… Read More »

## Modify array to maximize sum of adjacent differencesMarch 23, 2017

Given an array, we need to modify values of this array in such a way that sum of absolute differences between two consecutive elements is… Read More »

## Count of strings that can be formed using a, b and c under given constraintsMarch 19, 2017

Given a length n, count the number of strings of length n that can be made using ‘a’, ‘b’ and ‘c’ with at-most one ‘b’… Read More »