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

## Find the number of Chicks in a Zoo at Nth day

Given that a zoo has a single chick. A chick gives birth to 2 chicks everyday and the life expectancy of a chick is 6… Read More »

## Queries to check if string B exists as substring in string A

Given two strings A, B and some queries consisting of an integer i, the task is to check whether the sub-string of A starting from… Read More »

## Find maximum topics to prepare in order to pass the exam

Given three integer n, h and p where n is the number of topics, h is the time left (in hours) and p is the… Read More »

## Number of ways to divide an array into K equal sum sub-arrays

Given an integer K and an array arr[] of N integers, the task is to find the number of ways to split the array into… Read More »

## Number of subsets with zero sum

Given an array ‘arr’ consisting of integers, the task is to find the number of subsets such that their sum is equal to zero. Empty… Read More »

## Maximum sum in an array such that every element has exactly one adjacent element to it

Given an array arr[] of N integers, you can select some indexes such that every selected index has exactly one other selected index adjacent to… Read More »

## Maximum Sum Subsequence of length k

Given an array sequence [A1, A2 …An], the task is to find the maximum possible sum of increasing subsequence S of length k such that… Read More »

## Greedy approach vs Dynamic programming

A Greedy algorithm is an algorithmic paradigm that builds up a solution piece by piece, always choosing the next piece that offers the most obvious… Read More »

## Generate all unique partitions of an integer | Set 2

Given a positive integer n, the task is to generate all possible unique ways to represent n as sum of positive integers. Examples: Input: 4… Read More »

## Queries for bitwise OR in the given matrix

Given an N * N matrix mat[][] consisting of non-negative integers and some queries consisting of top-left and bottom-right corner of the sub-matrix, the task… Read More »

## Queries for bitwise AND in the given matrix

Given an N * N matrix mat[][] consisting of non-negative integers and some queries consisting of top-left and bottom-right corner of the sub-matrix, the task… Read More »

## Queries for bitwise AND in the index range [L, R] of the given array

Given an array arr[] of N and Q queries consisting of a range [L, R]. the task is to find the bit-wise AND of all… Read More »

## Queries for bitwise OR in the index range [L, R] of the given array

Given an array arr[] of N and Q queries consisting of a range [L, R]. the task is to find the bit-wise OR of all… Read More »

## Distinct palindromic sub-strings of the given string using Dynamic Programming

Given a string str of lowercase alphabets, the task is to find all distinct palindromic sub-strings of the given string. Examples: Input: str = “abaaa”… Read More »

## Maximum sum such that no two elements are adjacent | Set 2

Given an array of positive numbers, find the maximum sum of a subsequence with the constraint that no 2 numbers in the sequence should be… Read More »