Amazon interview question

To do a leetcode problem