Prerequisites : LCS, LISGiven two arrays, find length of the longest common increasing subsequence [LCIS] and print one of such sequences (multiple sequences may exist)Suppose… Read More

# Tag Archives: subsequence

Given a string, find out if the string is K-Palindrome or not. A k-palindrome string transforms into a palindrome on removing at most k characters… Read More

Given a binary string, count minimum number of subsequences to be removed to make it an empty string. Examples : Input: str[] = "10001" Output:… Read More

Given two strings, find the length of longest subsequence present in both of them. Examples: LCS for input Sequences “ABCDGH” and “AEDFHR” is “ADH” of… Read More

Subarray/Substring A subbarray is a contiguous part of array. An array that is inside another array. For example, consider the array [1, 2, 3, 4],… Read More

The longest Zig-Zag subsequence problem is to find length of the longest subsequence of given sequence such that all elements of this are alternating. If a… Read More

Given a string, find the length of the longest repeating subsequence such that the two subsequences don’t have same string character at the same position,… Read More

Given an array of integers, find the length of the longest sub-sequence such that elements in the subsequence are consecutive integers, the consecutive numbers can… Read More

Given two strings str1 and str2, the task is to find the length of the shortest string that has both str1 and str2 as subsequences.… Read More

Given two strings str1 and str2, find if str1 is a subsequence of str2. A subsequence is a sequence that can be derived from another… Read More

Given a number as a string, find the number of contiguous subsequences which recursively add up to 9

Given a number as a string, write a function to find the number of substrings (or contiguous subsequences) of the given string which recursively add… Read More

Given two sequences, print the longest subsequence present in both of them. Examples: LCS for input Sequences “ABCDGH” and “AEDFHR” is “ADH” of length 3.… Read More

Given a sequence of non-negative integers, find the subsequence of length 3 having maximum product with the numbers of the subsequence being in ascending order.… Read More

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… Read More

Given an array of n integers, find the 3 elements such that a[i] < a[j] < a[k] and i < j < k in 0(n)… Read More