Amazon interview question

OA was a leetcode medium