modified lcsDP.js