Skip to content

Category Archives: Dynamic Programming

Given an integer N, the task is to count the numbers up to N having an absolute difference of at most K between any two… Read More
Given an array arr[], the task is to maximize the sum of even-indexed elements by reversing a subarray and print the maximum sum obtained. Examples: … Read More
We all know that Fibonacci numbers (Fn) are defined by the recurrence relation   Fibonacci Numbers (Fn) = F(n-1) + F(n-2) with seed values F0 = 0 and… Read More
Given a weighted directed graph consisting of V vertices and E edges. The task is to print the cyclic path whose sum of weight is… Read More
Given an array arr[] of size N, the task is to find the number of non-empty subsequences from the given array such that no two… Read More
Given a matrix of size N x M and an integer X, the task is to find the number of sub-squares in the matrix with… Read More
Given a Directed Graph and two vertices in it, check whether there is a path from the first given vertex to second. Example:  Consider the… Read More
Given an integer array arr of size N. The task is to find the maximum number of splits such that each split has sum divisible… Read More
Given a rod of length N meters, and the rod can be cut in only 3 sizes A, B and C. The task is to… Read More
Given an undirected graph having N vertices and M edges and each vertex is associated with a cost and a source vertex S is given.… Read More
Given an array arr[] of N numbers. We can merge two adjacent numbers into one and the cost of merging the two numbers is equal… Read More
Given an array arr[] of N integers, and a range L to R, the task is to find the total number of elements in the… Read More
Given a string S of size N, the task is to count the occurrences of all the prefixes of the given string S. Examples:   Input:… Read More