← Practice · Dynamic programming
Longest Common Subsequence Medium
Given two strings text1 and text2, return the length of their longest common subsequence (characters in order but not necessarily contiguous), or 0 if there is none.
Examples
"abcde", "ace" -> 3 ("ace")"abc", "def" -> 0
Define a function named longestCommonSubsequence in JavaScript.
00:00
JavaScript · Tab indents · Ctrl/⌘+Enter runs the tests