All Problems
hardFunctions

Longest Common Subsequence

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

SAMPLE INPUT

ABCBDAB
BDCABA

SAMPLE OUTPUT

4

CONSTRAINTS

  • 1 <= len(s1), len(s2) <= 1000

Explanation: Use dynamic programming with a 2D table.

Code Editor
Output
Click "Run" to see output...