Algorithm from dynamic programming. It finds the longest
common sub-sequence of two strings. For example for strings 'abcd'
and 'axxcda' the longest common sub-sequence is 'acd'.
Parameters:
Name | Type | Description |
---|---|---|
first |
String
|
input string. |
second |
String
|
input string. |
Returns:
- Type:
-
Array
Longest common subsequence.
Example
var subsequence = require('path-to-algorithms/src/searching/'+
'longest-common-subsequence').longestCommonSubsequence;
console.log(subsequence('abcd', 'axxcda'); // 'acd'