Duolingo interview question

A medium level difficulty SQL problem