Adyen Interview Question

complexity of the solution