Good explanation of LCS algorithm: https://ics.uci.edu/~eppstein/161/960229.html