Amazon interview question

Question with list of strings.