Dynamic programming save time!!!!