Pregunta de entrevista de Grab

SQL question, with CTE implementation. Joins