Given two sequences word1 and word2, return the length of their longest common subsequence (LCS). A subsequence is formed by deleting zero or more elements without changing the order of the remaining elements. If no common subsequence exists, return 0.
Input
word1: a sequence (string or array)
word2: a sequence (string or array)
Output
The length of the longest common subsequence.
Examples
Example 1
Inputword1 = [1, 3, 5], word2 = [2, 4, 6]
Output0
Example 2
Inputword1 = [1], word2 = [2]
Output0
Constraints
0 <= word1.length, word2.length <= 1000.