Back to problems

Longest Common Subsequence-Substring

Algorithm · Microsoft · Medium

You are given two strings, x and y. Your task is to find the length of the longest string that is a subsequence of x and simultaneously a substring of y. If no such non-empty string exists, return 0. A subsequence is obtained by removing zero or more characters from a string while preserving the order of the remaining characters. A substring is a contiguous block of one or more characters within a string. Constraints: 1 ≤ x.length(), y.length() ≤ 1000 Example 1: Input: x =…

Checking your access…