Variations of LIS | DP-21 Last Updated : 03 Jun, 2021 Summarize Comments Improve Suggest changes Share Like Article Like Report We have discussed Dynamic Programming solution for Longest Increasing Subsequence problem in this post and a O(nLogn) solution in this post. Following are commonly asked variations of the standard LIS problem. 1. Building Bridges: Consider a 2-D map with a horizontal river passing through its center. There are n cities on the southern bank with x-coordinates a(1) ... a(n) and n cities on the northern bank with x-coordinates b(1) ... b(n). You want to connect as many north-south pairs of cities as possible with bridges such that no two bridges cross. When connecting cities, you can only connect city i on the northern bank to city i on the southern bank. 8 1 4 3 5 2 6 7 <---- Cities on the other bank of river----> -------------------------------------------- <--------------- River---------------> -------------------------------------------- 1 2 3 4 5 6 7 8 <------- Cities on one bank of river-------> Source: Dynamic Programming Practice Problems. The link also has well explained solution for the problem. The solution for this problem has been published here. 2. Maximum Sum Increasing Subsequence: Given an array of n positive integers. Write a program to find the maximum sum subsequence of the given array such that the integers in the subsequence are sorted in increasing order. For example, if input is {1, 101, 2, 3, 100, 4, 5}, then output should be {1, 2, 3, 100}. The solution to this problem has been published here. 3. The Longest Chain You are given pairs of numbers. In a pair, the first number is smaller with respect to the second number. Suppose you have two sets (a, b) and (c, d), the second set can follow the first set if b < c. So you can form a long chain in the similar fashion. Find the longest chain which can be formed. The solution to this problem has been published here. 4. Box Stacking You are given a set of n types of rectangular 3-D boxes, where the i^th box has height h(i), width w(i) and depth d(i) (all real numbers). You want to create a stack of boxes which is as tall as possible, but you can only stack a box on top of another box if the dimensions of the 2-D base of the lower box are each strictly larger than those of the 2-D base of the higher box. Of course, you can rotate a box so that any side functions as its base. It is also allowable to use multiple instances of the same type of box. Source: Dynamic Programming Practice Problems. The link also has well explained solution for the problem. Comment More infoAdvertise with us Next Article DP Standard Problem Variations K kartik Follow Improve Article Tags : Dynamic Programming DSA subsequence LIS Practice Tags : Dynamic Programming Similar Reads DP Standard Problem Variations When we solve Dynamic Programming problems, we try to find a pattern by matching pattern with a standard DP problem. This is generally recommended to solve new DP problems.Problems Based on FibonacciNth Fibonacci NumberClimbing StairsLucas NumbersDudeney's Cow Tribonacci NumbersClimbing Stairs with 1 min read A Space Optimized Solution of LCS Given two strings, s1 and s2, the task is to find the length of the Longest Common Subsequence. If there is no common subsequence, return 0.Examples:Input: s1 = âABCDGHâ, s2 = âAEDFHRâOutput: 3Explanation: The longest subsequence present in both strings is "ADH".Input: s1 = âAGGTABâ, s2 = âGXTXAYBâO 13 min read Dynamic Programming or DP Dynamic Programming is an algorithmic technique with the following properties.It is mainly an optimization over plain recursion. Wherever we see a recursive solution that has repeated calls for the same inputs, we can optimize it using Dynamic Programming. The idea is to simply store the results of 3 min read Digit DP | Introduction Prerequisite : How to solve a Dynamic Programming Problem ?There are many types of problems that ask to count the number of integers 'x' between two integers say 'a' and 'b' such that x satisfies a specific property that can be related to its digits.So, if we say G(x) tells the number of such intege 14 min read DP Problems Topic Wise DP Problems on MathsFibonacci NumbersTribonacci NumbersLucas NumberBinomial CoefficientPascal's Triangle GenerationNth Row of Pascal TriangleCatalan Number Matrix Chain MultiplicationDP Problems on StringsDecode WaysLongest Palindromic SubstringLongest Common SubstringEdit DistanceWord BreakPalindro 1 min read Longest Common Subsequence | DP using Memoization Given two strings s1 and s2, the task is to find the length of the longest common subsequence present in both of them. Examples: Input: s1 = âABCDGHâ, s2 = âAEDFHRâ Output: 3 LCS for input Sequences âAGGTABâ and âGXTXAYBâ is âGTABâ of length 4. Input: s1 = âstriverâ, s2 = ârajâ Output: 1 The naive s 13 min read Like