Citadel interview question

It was a Leetcode medium question