Amazon interview question

OA: LC Medium Interview: LC Medium