Solution for interview question.