# Tag Archives: subsequence

Subarray/Substring A subarray 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, 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
Given an array arr[0 … n-1] containing n positive integers, a subsequence of arr[] is called Bitonic if it is first increasing, then decreasing. Write… Read More
Given an array of random numbers. Find longest increasing subsequence (LIS) in the array. I know many of you might have read recursive and dynamic programming… Read More
Given a sequence, find the length of the longest palindromic subsequence in it.  As another example, if the given sequence is “BBABCBCAB”, then the… Read More
Given two integers k and n, write a function that prints all the sequences of length k composed of numbers 1,2..n. You need to print… Read More