X interview question

Four coding questions ranging from easy to hard.