Guardio interview question

sql with window functions and ctes