Citadel Interview Question

It was a leetcode medium problem