Domanda di colloquio di BNY

Can you describe this algorithm's time and space efficiency.