Pregunta de entrevista de Tata Consultancy Services

Gave two SQL queries and an algorithm of a simple string problem to write on paper.