Domanda di colloquio di JPMorganChase

time and space complexity of the algorithm