HackerEarth Candies problem solution - TheCScience