Domanda di colloquio di Robinhood

Typical leetcode question with two steps