Pergunta de entrevista da empresa Glovo

What is the time and space complexity of your solution?