Solved some dynamic programming problems