TikTok Interview Question

Leetcode question on maximizing a sequence in an array