Domanda di colloquio di Walmart Global Tech

Space and time complexity for an easy algorithm question