Amazon interview question

logical Star method