357 Dynamic Programming Solution