# Category Archives: Dynamic Programming (adsbygoogle = window.adsbygoogle || []).push({});

## Number of ways to reach the end of matrix with non-zero AND value

Given an N * N matrix arr[][] consisting of non-negative integers, the task is to find the number of ways to reach arr[N – 1][N… Read More »

## Find minimum steps required to reach the end of a matrix | Set 2

Given a 2d-matrix consisting of positive integers, the task is to find the minimum number of steps required to reach the end of the matrix.… Read More »

## Find minimum steps required to reach the end of a matrix | Set – 1

Given a 2d-matrix consisting of positive integers, the task is to find the minimum number of steps required to reach the end(leftmost-bottom cell) of the… Read More »

## Optimal Strategy for a Game | Set 2

Problem statement: Consider a row of n coins of values v1 . . . vn, where n is even. We play a game against an… Read More »

## Minimum number of sub-strings of a string such that all are power of 5

Given a binary string str. The task is to find the smallest positive integer C such that the binary string can be cut into C… Read More »

## Maximum sum path in a matrix from top to bottom and back

Given a matrix of dimension N * M. The task is find the maximum sum of path from arr to arr[N – 1][M – 1]… Read More »

## Bellman Ford Algorithm (Simple Implementation)

We have introduced Bellman Ford and discussed on implementation here. Input: Graph and a source vertex src Output: Shortest distance to all vertices from src.… Read More »

## Count number of subsets whose median is also present in the same subset

Given an array arr[] of size N, the task is to count the number of ways we can select a subset from the given array… Read More »

## Minimum number of cubes whose sum equals to given number N

Given an integer n, the task is to find the minimum number of cubes whose sum equals to N. Examples: Input: N = 496 Output:… Read More »

## Maximize the subarray sum after multiplying all elements of any subarray with X

Given an array arr[] of N integers and an integer X. We can choose any sub-array and multiply all its element by X. After multiplication,… Read More »

## Minimum number greater than the maximum of array which cannot be formed using the numbers in the array

Given an array arr[] of integers, the task is to find the minimum number greater than the maximum element from the array which cannot be… Read More »

## Count pairs of non-overlapping palindromic sub-strings of the given string

Given a string S. The task is to count the non-overlapping pairs of palindromic sub-strings S1 and S2 such that the strings should be S1[L1…R1]… Read More »

## Queries to check if substring[L…R] is palindrome or not

Given a string str and Q queries. Every query consists of two numbers L and R. The task is to print if the sub-string[L…R] is… Read More »

## Length of the longest increasing subsequence such that no two adjacent elements are coprime

Given an array arr[] of size N. The task is to find the length of the longest subsequence from the given array such that the… Read More »

## Find the number of binary strings of length N with at least 3 consecutive 1s

Given an integer N. The task is to find the number of all possible distinct binary strings of length N which have at least 3… Read More »