PayPal interview question

Wavy array, right from leetcode