Tag Archives: subsequence

Longest Increasing Odd Even Subsequence

Given an array of size n. The problem is to find the length of the subsequence in the given array such that all the elements… Read More »

Number of palindromic subsequences of length k

Given a string S of length n and a positive integer k. The task is to find number of Palindromic Subsequences of length k. Examples:… Read More »

Number of GP (Geometric Progression) subsequences of size 3

Given n elements and a ratio r, find the number of G.P. subsequences with length 3. A subsequence is considered GP with length 3 with… Read More »

Longest subsequence having equal numbers of 0 and 1

Given a binary array, the task is find the size of the largest sub_sequence which having equal number of zeros and one. Input : arr[]… Read More »

Given a large number, check if a subsequence of digits is divisible by 8

Given a number of at most 100 digits. We have to check if it is possible, after removing certain digits, to obtain a number of… Read More »

Print all subsequences of a string | Iterative Method

Given a string s, print all possible subsequences of the given string in an iterative manner. We have already discussed Recursive method to print all… Read More »

Longest subsequence of the form 0*1*0* in a binary string

Given a binary string, find the longest subsequence of the form (0)*(1)*(0)* in it. Basically we need to divide the string into 3 non overlapping… Read More »

Longest subsequence with no 0 after 1

Given a binary array, find length of the longest subsequence such that there is no 0 after a 1. Examples: Input : 1 1 0… Read More »

Powers of two and subsequences

Given an array of size N, find count of subsequences which when multiplied result in a number which is a power of 2. Examples: Input… Read More »

Subsequences of size three in an array whose sum is divisible by m

Given an array A[] (1

Length of Longest Balanced Subsequence

Given a string S, find the length of longest balanced subsequence in it. A balanced string is defined as:- A Null string is a balanced… Read More »

Lexicographically largest subsequence such that every character occurs at least k times

Given a string S and an integer K. The task is to find lexicographically largest subsequence of S, say T, such that every character in… Read More »

Count all subsequences having product less than K

Given a non negative array, find the number of subsequences having product smaller than K. Examples: Input : [1, 2, 3, 4] k = 10… Read More »

Non-decreasing subsequence of size k with minimum sum

Given a sequence of n integers, you have to find out the non-decreasing subsequence of length k with minimum sum. If no sequence exists output… Read More »

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

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 »