Revolut Interview Question

Python logic problem of live coding