FastPrepFastPrep
Problem Brief

Find Longest Subsequence Common to X as Substring in Y (MLE :)

NEW GRADOA
See Salesforce online assessment and hiring insights

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.

1Example 1

Input
x = "hackerranks", y = "hackers"
Output
7
Explanation
The entire string "hackers" is a substring of y and also a subsequence of x (characters appear in order). The maximum length is 7.
public int findLongestSubsequenceCommonToXAsSubstringInY(String x, String y) {
  // write your code here
}
Input

x

"hackerranks"

y

"hackers"

Output

7

Sign in to submit your solution.