Amazon interview question

Question given was a LC medium