Solve 121 with dynamic programming