Amazon interview question

Q: Can you solve this coding problem?