Upstart Interview Question

A DP question of array