add dynamic programming version of problem 5