Amazon Interview Question

Both questions were based on arrays