Wednesday, 1 Dec 2021
Category: subsequence

Given a string S, the task is to find the lexicographically largest subsequence that can be formed using all distinct characters only once from the given string.Examples:Input: S = ababcOutput: bacExplanation:All possible subsequences containing all the characters in S exactly once are {“abc”, “bac”}. The lexicograohically maximum among all the subsequences  is “bac”.Input: S = […]

Given an array arr[] consisting of N positive integers, the task is to find the number of subsequences of length 4 having product of the first three elements equal to the fourth element.Examples:Input: arr[] = {10, 2, 2, 7, 40, 160}Output: 2Explanation:Following are the subsequences of length 4 satisfying the given criteria:{10, 2, 2, 40}, […]

Minimum number of removals required such that no subsequence of length 2 occurs more than onceGiven a string S consisting of N lowercase characters, the task is to modify the given string such that no subsequence of length two repeats in the string by removing minimum number of characters.Examples:Input: S = “abcaadbcd”Output: abcdExplanation: Removing the […]

Maximum number of plates that can be placed from top to bottom in increasing order of sizeGiven a 2D array plates[][] of size N, which each row representing the length and width of a N rectangular plates, the task is to find the maximum number of plates that can be placed on one another. Note: […]