Visa Inc. interview question

Gave me a task to solve