Question d’entretien chez Google

Leetcode hard question on their platform