Navan interview question

Hard Leetcode Problem. Not really sure which one.