/lcs

A Javascript implementation of the LCS algorithm

Primary LanguageJavaScript

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();