Amazon Interview Question

It was a test code of the team was interviewing me.