Longest common subsequence
Mediumdynamic programmingstring
A subsequence keeps characters in order but not necessarily adjacent (ace from abcde). Return the length of the longest subsequence common to a and b.
Example 1
Input: a = "abcde", b = "ace" Output: 3
Example 2
Input: a = "abc", b = "def" Output: 0
Constraints
- 1 ≤ a.length, b.length ≤ 1000
- Lowercase English letters
Submit checks your solution against 9 tests, including hidden ones.
/**
* @param {string} a
* @param {string} b
* @return {int}
*/
function longestCommonSubsequence(a, b) {
}