Machinify Interview Question

Solve an SQL question, the answer required LEAD and LAG