# Category Archives: Dynamic Programming

Given a set of numbers, find the Length of the Longest Arithmetic Progression (LLAP) in it. Examples:  set[] = {1, 7, 10, 15, 27, 29} output… Read More
A car factory has two assembly lines, each with n stations. A station is denoted by Si,j where i is either 1 or 2 and… Read More
Given three strings A, B and C. Write a function that checks whether C is an interleaving of A and B. C is said to… Read More
Given an input string and a dictionary of words, find out if the input string can be segmented into a space-separated sequence of dictionary words.… Read More
Consider a row of n coins of values v1 . . . vn, where n is even. We play a game against an opponent by… Read More
Given n dice each with m faces, numbered from 1 to m, find the number of ways to get sum X. X is the summation… Read More
Given two strings ‘X’ and ‘Y’, find the length of the longest common substring.  Examples :  Input : X = “GeeksforGeeks”, y = “GeeksQuiz” Output :… Read More
Given a string str, the task is to find the minimum number of characters to be inserted to convert it to palindrome.Before we go further,… Read More
You are given a one dimensional array that may contain both positive and negative integers, find the sum of contiguous subarray of numbers which… Read More
Given a 2D array, find the maximum sum subarray in it. For example, in the following 2D array, the maximum sum subarray is highlighted with… Read More
Given a Binary Tree, find size of the Largest Independent Set(LIS) in it. A subset of all tree nodes is an independent set if there… Read More
Given a number n, write an efficient function to print all prime factors of n. For example, if the input number is 12, then output… Read More
Given a set of non-negative integers, and a value sum, determine if there is a subset of the given set with sum equal to… Read More
Given a sorted array key [0.. n-1] of search keys and an array freq[0.. n-1] of frequency counts, where freq[i] is the number of searches… Read More
There are some glasses with equal capacity as 1 litre. The glasses are kept as follows:   1 2 3 4 5 6 7 8 9… Read More