Amazon interview question

I think all these were from leetcode