Visa Inc. interview question

HackerRank question