Amazon interview question

1)based on matrix 2)on arrays