Amazon interview question

Problems were from easy to medium on Leetcode