Adyen interview question

how to optimise your algorithm