X interview question

Basic algorithm questions.