Pergunta de entrevista da empresa Amazon

time complexity and space complexity