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.More Salesforce problems
- Minimize Total Input Cost (for LTMS)Seen Jun 2026
- Count Prime StringsONSITE INTERVIEW · Seen Jun 2026
- Final Pod Counts After LogsOA · Seen May 2026
- ATM Queue Exit OrderPHONE SCREEN · Seen May 2026
- Good Ways to Split an ArrayPHONE SCREEN · Seen May 2026
- Generate Seen Binary StringsOA · Seen May 2026
- Update Pod Counts From LogsOA · Seen May 2026
- Minimum Removals to Balance ArrayOA · Seen May 2026