Amazon Interview Question

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