Domanda di colloquio di Whatnot

Leetcode question with additional questions about time complexity.