Pregunta de entrevista de Walmart Global Tech

Space and time complexity for an easy algorithm question