Similar Items: Dynamic programming.