LCSM simple and dynamic programming methods