Revolut interview question

How would you solve the following question using python etc