Longest Common Subsequence
Given two strings text1 and text2, return the length of their longest common subsequence. If there is no common subsequence, return 0.

30:00

Longest Common Subsequence
medium
Topics
Companies

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

Example 1:
Input: {"text1":"abcde","text2":"ace"}
Output: 3
Constraints:
  • 1text1.length,text2.length10001 \leq \text{text}_1.\text{length}, \text{text}_2.\text{length} \leq 1000

  • text1 and text2 consist of only lowercase English letters.

Input
arr ={"text1":"abcde","text2":"ace"}

Init DP table with 0s

a

c

e

0

0

0

0

a

0

0

0

0

b

0

0

0

0

c

0

0

0

0

d

0

0

0

0

e

0

0

0

0

Variables
No variables to display
DepthFunction Call
Stack empty
0/31