# Tag Archives: Algorithms-Dynamic Programming

## Print the Maximum Subarray Sum

Given an array arr[], the task is to find the elements of a contiguous subarray of numbers which has the largest sum. Examples: Input: arr… Read More »

## Minimum steps to convert all top left to bottom right paths in Matrix as palindrome | Set 2

Given a matrix mat[][] with N rows and M columns. The task is to find the minimum number of changes required in the matrix such… Read More »

## Largest subsequence such that all indices and all values are multiples individually

Given an array arr[] of N positive integers, the task is to find the largest strictly increasing subsequence of arr[] such that the indices of… Read More »

## Count of Binary strings of length N having atmost M consecutive 1s or 0s alternatively exactly K times

Given three integers, N, K and M. The task is to find out the number of binary strings of length N which always starts with… Read More »

## Maximum of all distances to the nearest 1 cell from any 0 cell in a Binary matrix

Given a Matrix of size N*N filled with 1‘s and 0‘s, the task is to find the maximum distance from a 0-cell to its nearest… Read More »

## Sum of Digits of the Good Strings

A string is called good if it is made with only digits 0 to 9 and adjacent elements are different. The task is to find… Read More »

## Minimal product subsequence where adjacent elements are separated by a maximum distance of K

Given an array arr[] and an integer K, the task is to find out the minimum product of a subsequence where adjacent elements of the… Read More »

## Paths with maximum number of ‘a’ from (1, 1) to (X, Y) vertically or horizontally

Given a N X N matrix consisting of characters. Also given are Q queries, where each query contains a co-ordinate (X, Y). For every query,… Read More »

## Sum of elements of all partitions of number such that no element is less than K

Given an integer N, the task is to find an aggregate sum of all integer partitions of this number such that each partition does not… Read More »

## Water Jug Problem using Memoization

Given two jugs with the maximum capacity of m and n liters respectively. The jugs don’t have markings on them which can help us to… Read More »

## Number of paths from source to destination in a directed acyclic graph

Given a Directed Acyclic Graph with n vertices and m edges. The task is to find the number of different paths that exist from a… Read More »

## Tetranacci Numbers

The tetranacci numbers are a generalization of the Fibonacci numbers defined by the recurrence relation T(n) = T(n-1) + T(n-2) + T(n-3) + T(n-4) with… Read More »

## Weird Number

In number theory, a weird number is a natural number that is abundant but not semiperfect. In other words, the sum of the proper divisors… Read More »

## Number of ways to reach Nth floor by taking at-most K leaps

Given N number of stairs. Also given the number of steps that one can cover at most in one leap (K). The task is to… Read More »

## Number of ways to represent a number as sum of k fibonacci numbers

Given two numbers N and K. Find the number of ways to represent N as the sum of K Fibonacci numbers. Examples: Input : n… Read More »