Back to problems

Longest Subsequence of X That Is a Substring of Y

Algorithm · Salesforce · Medium

Requirements You are given two strings, x and y, containing lowercase English letters. A subsequence of x is formed by removing any number of characters without changing the order of those that remain. A substring of y must occupy a contiguous range of positions in y. Return the length of the longest string satisfying both conditions: it is a subsequence of x and a substring of y. Examples Notes Keep the two definitions distinct: a subsequence may skip characters, whereas a…

Checking your access…