Amazon Interview Question

1)based on matrix 2)on arrays