dynamic prog - reminds of LIS