Domanda di colloquio di Citadel

Leet code type of question with time and space complexity.