Amazon Interview Question

Q: Can you solve this coding problem?