X Interview Question

One SQL question. Two algorithms questions.