T-Systems interview question

Candies Distribution