CodeOath
← All problems

Longest Common Subsequence

Medium
dynamic-programmingstrings

Given two strings text1 and text2, return the length of their longest common subsequence, or 0 if there is no common subsequence.

Example:

Input: text1 = "abcde", text2 = "ace"
Output: 3
Explanation: The longest common subsequence is "ace" and its length is 3.

Constraints:

  • 1 <= text1.length, text2.length <= 1000