Domanda di colloquio di Google

It is like a leetcode question