Given an N*M matrix containing only 0s and 1s, the task is to count the number of square submatrices containing all 1s.Examples: Input: arr[][] =… Read More

# Category Archives: Dynamic Programming

Given an array arr[] of length N, the task is to find the number of strictly increasing sub-sequences in the given array. Examples: Attention reader! Don’t… Read More

Given an array of integer arr[] and an integer k, the task is to find the median of each window of size k starting from… Read More

Given a N x M matrix where N is the number of rows and M is the number of columns in the given matrix and… Read More

Given a number N, the task is to build N blocks from 1 block by performing following operation: Double the number of blocks present in… Read More

Given three integers X, Y and Z, the task is to find the sum of all the numbers formed having 4 at most X times,… Read More

Given an array arr[] of size N. The task is to find the size of the set of numbers from the given array such that… Read More

Given a binary tree of 0s and 1s, the task is to find the maximum number of 1s in any path in the tree. The… Read More

Given a sorted array of length ‘N’ and an integer ‘K'(K<N), the task is to remove exactly ‘K’ elements from the array such that the… Read More

Given a binary string S of length N, the task is to find the length of the longest sub-sequence in it which is divisible by… Read More

Given a binary string S of length N, the task is to find the number of sub-sequences of non-zero length which are divisible by 3.… Read More

Given a character X and a string Y of length N and the task is to find the number of ways to convert X to… Read More

Given an array arr[], the task is to find out the maximum obtainable value. The user is allowed to add or multiply the two consecutive… Read More

Given an array arr[] consisting of N elements, the task is to remove minimum number of elements from the ends of the array such that… Read More

Given an array arr[] of N integers, the task is to find the largest subset of arr[] such that in every pair of numbers from… Read More