TikTok Interview Question

A dynamic programming question to maximize candy taken from trick or treating.