Skip to content

Category Archives: Dynamic Programming

The term “Memoization” comes from the Latin word “memorandum” (to remember), which is commonly shortened to “memo” in American English, and which means “to transform… Read More
Given two arrays arr1[] and arr2[] of size N each, the task is to find the minimum number of interchange of the same indexed elements… Read More
Given a number N and a mapping of letters to each integer from 1 to 8, which are: {1: ‘abc’, 2: ‘def’, 3: ‘ghi’, 4: ‘jkl’,… Read More
Given a string S of length N, the task is to find the number of unique subsequences of the string for each length from 0… Read More
Given an array arr[] of N strings, and Q queries where each of the queries contains some characters, the task is to check if for… Read More
Dynamic programming (DP) is arguably the most important tool in a competitive programmer’s repertoire. There are several optimizations in DP that reduce the time complexity… Read More
Knuth’s optimization is a very powerful tool in dynamic programming, that can be used to reduce the time complexity of the solutions primarily from O(N3)… Read More
Given an array arr[] of size N such that the sum of all the array elements does not exceed N, and array queries[] containing Q… Read More
Given a binary array arr[] of size N, the task is to find the count of distinct alternating triplets. Note: A triplet is alternating if… Read More
Given an array A[] having N positive integers, the task is to perform the following operations and maximize the sum obtained while reducing the array:… Read More
There are N stairs, a person standing at the bottom wants to reach the top. The person can climb either 1 stair or 2 stairs… Read More
Given an array A[] of size N and a digit K. Find the number of sub-sequences of the array where the last digit of the… Read More
Given a matrix mat[][] of size N * M and an integer K, the task is to find a path from the top-left cell (0,… Read More
 Given an array arr[] of size N, the task is to count the minimum number of elements required to be removed from the given array… Read More

Start Your Coding Journey Now!