Amazon interview question

asked on leetcode no between 39