manrajgrover / algorithms-js

Consumable Data Structures and Algorithms library in JavaScript
MIT License
199 stars 128 forks source link

Implemented longest common subsequence algorithm #45

Open wbira opened 5 years ago

wbira commented 5 years ago

I want partially resolve #8 by adding implementation of Longest common subsequence

remes2000 commented 4 years ago

Hi, tests that you've written only check response value's length. Once I changed them to check an acctual algorithm result one of tests doesn't pass.

it('should find baba or abab for abaabbaaa and babab', () => {
    const stringA = 'abaabbaaa';
    const stringB = 'babab';

    const result = logestcommonsubsequence(stringA, stringB);
    assert.equal(['baba', 'abab'].indexOf(result) !== -1, true);
  });

I guess the problem is in your readSolution function. Let me know If you want to work on this. If the answer is negative. I'll be more than happy to fix this :)