Amazon interview question

There were 2 questions: Leetcode easy/medium