Amazon Interview Question

Fix the code to make it correct