Category: subsequence

Lexicographically largest subsequence containing all distinct characters only once

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 = […]

Continue Reading

Minimum number of removals required such that no subsequence of length 2 occurs more than once

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 […]

Continue Reading