Skip to content

Category Archives: Dynamic Programming

Given an array arr[] of size N, and an array Q[][] with each row representing a query of the form { X, Y }, the… Read More
Given two arrays firstArr[], consisting of distinct elements only, and secondArr[], the task is to find the length of LCS between these 2 arrays. Examples:… Read More
Given an array arr[] of size N, the task is to find a value for each index such that the value at index i is… Read More
Given two integers M and N, the task is to find the number of N-length arrays possible having non-equal adjacent elements lying in the range… Read More
Given three positive integers L, R and K, the task is to count the numbers in the range [L, R] whose product of digits is… Read More
Given a positive integer N, the task is to find the value of (22 * X), where X is the binary representation of N. Since… Read More
Given a binary string S of length N consisting of 0s, 1s, and “?”, where “?” can be replaced by either 0 or 1, the… Read More
Given a 2D matrix mat[][] of size N * M, the task is to find the median of Bitwise XOR of all possible submatrices from… Read More
Given an array arr[] of even length N and an integer K, the task is to minimize the count of replacing array elements by an… Read More
Given an array arr[] consisting of N characters, the task is to generate all possible combinations of at most X elements ( 1 ≤ X… Read More
Given an array of integers A[] consisting of N integers, find the number of triples of indices (i, j, k) such that A[i] & A[j]… Read More
Given an array arr[] of size N, the task is to find the count of all subsets from the given array whose product of is… Read More
Given an integer N, the task is to count the number of N-length strings consisting of lowercase vowels that can be generated based the following… Read More
Given an array arr[] of size N and an integer K, the task is to find the maximum subarray sum by removing at most K… Read More
Given a matrix, mat[][] of size N * M, the task is to find the minimum count of operations required to make all elements of… Read More