add dynamic programming algorithm example