LeetCode 1143 Longest Common Subsequence - Problem Statement

The problem

Find the length of the longest common subsequence of two strings.

A subsequence maintains relative order but doesn't need to be contiguous.

With text1 = "abcde", text2 = "ace":

  • "ace" is a subsequence of both.
  • Length: 33.

With text1 = "abc", text2 = "abc":

  • "abc" itself is common.
  • Length: 33.

With text1 = "abc", text2 = "def":

  • No common characters.
  • Length: 00.

Constraints: 11 \le text1.length, text2.length 1000\le 1000.