Pergunta de entrevista da empresa BMAT

Time and space complexity of the solution