More dynamic programming and recursion