Problem · Dynamic Programming
Find Longest Subsequence Common to X as Substring in Y (MLE :)
Learn this problemProblem statement
Given two strings x and y, find the longest subsequence of x that is also a substring of y. Return the maximum length of such a subsequence.
Function
findLongestSubsequenceCommonToXAsSubstringInY(x: String, y: String) → intExamples
Example 1
x = "hackerranks"y = "hackers"return = 7The entire string "hackers" is a substring of
y and also a subsequence of x (characters appear in order). The maximum length is 7.