Pergunta de entrevista da empresa Walmart Global Tech

Space and time complexity for an easy algorithm question