Pregunta de entrevista de Navan

Hard Leetcode Problem. Not really sure which one.