Category Archives: Dynamic Programming

Given two integers N and K, the task is to find the total number of ways of representing N as the sum of positive integers… 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 prices[] 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
Given two integers N and K, the task is to find the count of sequences of K elements from the range [1, N] where every… Read More
Given an array arr[] of length N and an integer X, the task is to find the number of subsets with a sum equal to… Read More
Given string str, the task is to find the minimum number of characters to be inserted to convert it to a palindrome. Before we go… Read More
Given string str, the task is to find the minimum number of characters to be inserted to convert it to a palindrome. Before we go… Read More
Given string str, the task is to find the minimum number of characters to be inserted to convert it to a palindrome. Before we go… Read More
Given a positive number N, the task is to find the number of ways to reach N from 2 wherein each operation one of the… Read More