Skip to content

Category Archives: Dynamic Programming

Given an array arr[] having N pair of integers of the form (x, y), the task is to maximize the sum y values in selected… Read More
Given three integers M, N and K, the task is to count all the possible paths from the cell (0, 0, 0) to cell (M-1,… Read More
Given a binary string S of size N, and a 2D array Q[][] of queries consisting of M pairs of the form {L, R}, the… Read More
Given two integers N and M (1 ≤ N, M ≤ 100) denoting the total number of 1s and 0s respectively. The task is to… Read More
Given an integer N and three N x N matrices X[][], Y[][], and Z[][], the task is to calculate the minimum cost required to reach… Read More
Given two points P1(x1, y1) and P2(x2, y2) of a matrix, the task is to find the minimum cost to reach P2 from P1 when:… Read More
Given an array arr[] containing integers. The task is to find the number of decreasing subarrays with a difference of 1.  Examples:  Input: arr[] =… Read More
For every node in an undirected tree, find the sum of length of paths from it to all other nodes, using Tree Rerooting technique. Rerooting… Read More
Given two arrays A and B of size N, the task is to maximize the sum of A[i]*B[i] across all values of i from 0… Read More
Given binary string str of size N, the task is to remove the minimum number of characters from the given binary string such that the… Read More
Given a positive integer K and a matrix grid of dimensions N * M consisting of characters ‘.’ and ‘#’, where ‘.’ represents the unblocked… Read More
Given two arrays arr1[] and arr2[] having N integers in non-decreasing order, the task is to find the count of non-decreasing arrays arr3[] of length… Read More
Type I: At most one transaction is allowed Given an array price[] of length N, representing the prices of the stocks on different days, the… Read More
Given an array of integers arr[], find the subsequence with maximum sum whose elements are first decreasing, then increasing, or vice versa, The subsequence can… Read More
Given an array arr[] of size N. The task is to find the maximum score that can be achieved by alternative minus – plus of… Read More

Start Your Coding Journey Now!