Amazon interview question

some coding question involving arrays