Skip to content

Latest commit

 

History

History
25 lines (16 loc) · 680 Bytes

readme.md

File metadata and controls

25 lines (16 loc) · 680 Bytes

Longest Common Subsequence in JS

This is an implementation of an algorithm to solve the longest common subsequence problem in Javascript.

Install

This is a node module, so install it with npm install erictrinh/lcs

Usage

var LCS = require('lcs');

var lcs = new LCS('abc', 'acd');

// length of the longest common subsequence
lcs.getLength(); // 2

// get the longest common subsequences (there may be more than one)
lcs.getSequences(); // [ 'ac' ]

// get the table generated by the algorithm
// see http://en.wikipedia.org/wiki/Longest_common_subsequence_problem
lcs.getTable();