JPMorganChase Interview Question

Both were array questions in python,