Google interview question

Related to strings and lists