Amazon Interview Question

array manipulation question using python