X interview question

One SQL question. Two algorithms questions.