Token.io interview question

Standard algorithm questions.