Skip to content

Tag Archives: LCS

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:… Read More
Most of the Dynamic Programming problems are solved in two ways:   Tabulation: Bottom Up Memoization: Top Down One of the easier approaches to solve most… Read More
Given two strings s1, s2 and K, find the length of the longest subsequence formed by consecutive segments of at least length K.Examples:   Input :… Read More
Given two strings A and B. The task is to count the number of ways to insert a character in string A to increase the… Read More
Given two string X, Y and an integer k. Now the task is to convert string X with the minimum cost such that the Longest… Read More
Given a sequence, print a longest palindromic subsequence of it. Examples :   Input : BBABCBCAB Output : BABCBAB The above output is the longest palindromic subsequence… Read More
Given a string, print the longest repeating subsequence such that the two subsequence don’t have same string character at same position, i.e., any i’th character… Read More
Given two sequence P and Q of numbers. The task is to find Longest Common Subsequence of two sequences if we are allowed to change… Read More
Compute the shortest string for a combination of two given strings such that the new string consist of both the strings as its subsequences.Examples:   Input… Read More
Given two strings S and T, find the length of the shortest subsequence in S which is not a subsequence in T. If no such… Read More
Given two strings ‘str1’ and ‘str2’ of size m and n respectively. The task is to remove/delete and insert the minimum number of characters from/in… Read More
Given two strings of lower alphabet characters, we need to find the number of ways to insert a character in the first string such that… Read More
Given 3 strings of all having length < 100,the task is to find the longest common sub-sequence in all three given sequences.Examples:   Input : str1… Read More
You are given two strings.Now you have to print all longest common sub-sequences in lexicographical order?Examples:   Input : str1 = "abcabcaa", str2 = "acbacba" Output:… Read More
Given two strings in lowercase, find the longest string whose permutations are subsequences of given two strings. The output longest string must be sorted.Examples:   Input… Read More