Given an array A[] of size N and a positive integer K, the task is to find the length of the longest subarray such that… Read More

# Category Archives: Dynamic Programming

Given two arrays arr[] and jumps[] consisting of N positive integers, the task for each array element arr[i] is to find the minimum number of… Read More

Given two arrays arr1[] and arr2[] of length M and N consisting of digits [0, 9] representing two numbers and an integer K(K ≤ M… Read More

Given two positive integers N and K, the task is to find the number of K length strings that can be generated from the first… Read More

Given an array arr[] of size N, the task is to count the number of longest increasing subsequences present in the given array. Examples: Input:… Read More

Given a binary array arr[] of size N and two players, A and B. The task is to minimize the score for player A by… Read More

Given a 2D matrix mat[][] of size N * M and a positive integer K, the task is to find the area of the smallest… Read More

Given an integer N, the task is to count all possible strings of length N consisting of vowels {a, e, i, o, u} that can… Read More

Given three positive integers N, X, and Y, the task is to count N-digit numbers containing of X or Y only as digits and the… Read More

Given an array, arr[] of size N, the task is to find the median of sums of all possible subsets of the given array. Examples:… Read More

Given an array arr[] consisting of N positive integers and the integers X and M, where 0 <= X < M, the task is to… Read More

Given a matrix arr[][] of dimensions 2 * N, the task is to maximize the sum possible by selecting at most one element from each… Read More

Given an integer X and integer N, the task is to find the number of unique paths starting from the root in N-ary tree such… Read More

Given an N-array tree of N nodes, rooted at 1, with edges in the form {u, v}, and an array values[] consisting of N integers.… Read More