Find Longest Subsequence Common to X as Substring in Y (MLE :)
Updated
Problem 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 = 7
The 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 interview questions
- Count Increasing TripletsONSITE INTERVIEW · Seen Nov 2026
- Longest Substring Without Repeating CharactersONSITE INTERVIEW · Seen Nov 2026
- Reverse a Sublist of a Linked ListONSITE INTERVIEW · Seen Nov 2026
- Rotting OrangesONSITE INTERVIEW · Seen Nov 2026
- 3Sum SmallerONSITE INTERVIEW · Seen Nov 2026
- Count Zero Request ServersONSITE INTERVIEW · Seen Nov 2026
- Count Subarrays With Product Equal to KOA · Seen Nov 2026
- Minimum No-Repeat Segments After One Character RemovalOA · Seen Nov 2026
- Get Message StatusOA · Seen Nov 2026
- Group Identical Tree LevelsONSITE INTERVIEW · Seen Oct 2026
Similar questions at other companies
- Lexicographically Smallest Grid Path with One Letter ChangeInfosys · OAInfosys interview questions
- Minimum Merge ConflictsAmazon · OA
- String Formation (Also for AI/ML Software Engineer Intern :)Snowflake · OASnowflake interview questions
- Distinct MovesMeesho · OA
- Compressed Representation SizeMicrosoft · OAMicrosoft interview questions
- Find Minimum OperationsIBM · OAIBM interview questions
- String Challenge (Generic)TikTok · OATikTok interview questions
- Maximize the Lottery IDCitadel · OACitadel interview questions
- Sum of All ValuesFlexport · OAFlexport interview questions
- Maximum Crayon Removal ScoreWells Fargo · OAWells Fargo interview questions