Citadel interview question

leetcode medium/hard - some behavioral