Pregunta de entrevista de Titan Company

Difficult SQL queries.