Domanda di colloquio di Jane Street

create algorithm and it's time complexity