Amazon interview question

Question 1: Leetcode easy 937 . Question 2: Leetoce medium 200.