Dynamic programming: 1D

Medium3 min read