Amazon interview question

Leetcode questions like 798, 281