Amazon interview question

fix this code with minimal access to resources