Amazon interview question

Leetcode array manipulation very easy, then a sorting based leetcode one