Citadel interview question

Pretty normal algorithm coding question