# Category Archives: Dynamic Programming

## Number of ways to arrange N items under given constraintsOctober 2, 2017

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 valuesOctober 1, 2017

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 arraysSeptember 26, 2017

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)) + xSeptember 24, 2017

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 »

## Remove array end element to maximize the sum of product

Given an array of N positive integers. We are allowed to remove element from either of the two ends i.e from the left side or… Read More »

## Maximize the binary matrix by filpping submatrix once

Given a binary matrix of R rows and C columns. We are allowed flip to any size of sub matrix. Flipping means changing 1 to… Read More »

## Count all triplets whose sum is equal to a perfect cubeSeptember 12, 2017

Given an array of n integers, count all different triplets whose sum is equal to the perfect cube i.e, for any i, j, k(i <… Read More »

## Maximum sum bitonic subarraySeptember 10, 2017

Given an array containing n numbers. The problem is to find the maximum sum bitonic subarray. A bitonic subarray is a subarray in which elements… Read More »

## Count ways to build street under given constraintsSeptember 2, 2017

There is a street of length n and as we know it has two sides. Therefore a total of 2 * n spots are available.… Read More »

## Maximum length subsequence with difference between adjacent elements as either 0 or 1September 1, 2017

Given an array of n integers. The problem is to find maximum length of the subsequence with difference between adjacent elements as either 0 or… Read More »

## Unique paths in a Grid with ObstaclesAugust 28, 2017

Given a grid of size m * n, let us assume you are starting at (1, 1) and your goal is to reach (m, n).… Read More »

## Largest rectangular sub-matrix whose sum is 0August 27, 2017

Given a 2D matrix, find the largest rectangular sub-matrix whose sum is 0. for example consider the following N x M input matrix Examples: Input… Read More »