Amazon Interview Question

fix this code with minimal access to resources