Solving My Amazon Phone Interview Question