Skip to content

Category Archives: Dynamic Programming

Given a 2-D array of N rows and M columns and an integer K. The task is to find whether is it possible to take… Read More
Given a binary matrix M where each element of the matrix will be 0 or 1, the task is to find the largest square that… Read More
Given an array arr[] consisting of positive integers, the task is to check whether we can modify the array by adding any of the elements… Read More
A number can always be represented as a sum of squares of other numbers. Note that 1 is a square, and we can always break… Read More
Given a digit sequence S, the task is to find the number of possible decodings of the given digit sequence where 1 represents ‘A’, 2… Read More
Given an integer array arr[] of N distinct elements and a positive integer K ( K <= N ). The task is to calculate the… Read More
Given an array arr[] of positive numbers, find the maximum sum of a subsequence with the constraint that no 2 numbers in the sequence should… Read More
Given string str. The task is to find the longest subsequence of str such that all the characters adjacent to each other in the subsequence… Read More
Given a matrix mat[][] and an integer K, the task is to find the maximum neighbor within an absolute distance of K for each element… Read More
Given an integer N, and an integer K, the task is to count the number of distinct ways to represent the number N as a… Read More
Given a matrix mat[][] and two integers K and S, the task is to count all K x K sub-matrix such that the sum of… Read More
Given a string str and Q queries in form of [L, R, K], the task is to find whether characters from the string from [L,… Read More
Given weights and profits of N items, put these items in a knapsack of capacity W. The task is to print all possible solutions to… Read More
Given a non-empty sequence S and a dictionary dict[] containing a list of non-empty words, print all possible ways to break the sentence in individual… Read More
Given an array arr[] of N integers and an integer M and the cost of selecting any array element(say x) at any day(say d), is… Read More