Guardio Interview Question

sql with window functions and ctes