Domanda di colloquio di Navan

Hard Leetcode Problem. Not really sure which one.