Find LCS of Two Strings
STRING
DYNAMIC PROGRAMMING

Problem

Given two strings s1 and s2, find the length of the longest common subsequence.

A subsequence is derived by deleting some or no characters from the string without altering the order of the remaining characters.

Return 0 if no common subsequence exists.

Examples

findLCSLength("abcdefg", "bdg") // return 3 // Why? The LCS is "bdg" findLCSLength("aggtab", "gxtxayb") // return 4 // Why? The LCS is "gtab"
Loading...
Loading...
Loading...