Domanda di colloquio di Dunzo

One Google tagged Leetcode question. One Codechef/Hackerrank question (hard).