Given a number K, and N bars of height from 1 to N, the task is to find the number of ways to arrange the… Read More

# Category Archives: Dynamic Programming

Given a vector of pairs, V[] denoting the width and height of N rectangles numbered from 1 to N, these rectangles are placed in contact… Read More

Given an array A[] of size N, and two numbers K and D, the task is to calculate the maximum subset-sum divisible by D possible… Read More

Given an array A[] of N positive numbers, the task is to find the maximum sum that can be formed which has no three consecutive… Read More

Given a positive integer N, the task is to count the number of N-digit numbers having absolute difference between consecutive digits in non-increasing order. Examples:… Read More

Given an array of pairs A[][] of size N, the task is to find the longest subsequences where the first element is increasing and the… Read More

Given two strings X and Y consisting of N and M characters, the task is to find the longest subsequence of a string X which… Read More

Given four integers N, M, A, and B, the task is to print all numbers ( in increasing order ) that can be obtained by… Read More

Given a 2D array, arr[][] denoting a list of coordinates of N vertices on 2D space that is already sorted by x-coordinates and y-coordinates, the… Read More

Given a 2d array, arr[][] and a piece of the chocolate bar of dimension N × M, the task is to find the minimum possible sum… Read More

Given a matrix mat[][] of dimensions N * M and a set of coordinates of cell coordinates[][] of size Q, the task is to find… Read More

Given a positive integer N, the task is to reduce N to 2 by performing the following operations minimum number of times: Operation 1: Divide… Read More

Given a binary string of size N, the task is to count the number of alternating substrings that are present in the string S. Examples: … Read More

Given an array A[] consisting of N non-negative integers, and an integer K, the task is to find the number of ways ‘+’ and ‘-‘… Read More