Ridgeline Interview Question

A leet code medium problem on arrays.