Pregunta de entrevista de Machinify

Solve an SQL question, the answer required LEAD and LAG