Back to course home
0% completed
Vote For New Content
Solution: Candy
Problem Statment
You are given ratings array of integers where ratings[i] is rating value assigned to the i<sup>th</sup> child. You are giving candies to these n children who are standing in single row.
Follow below rules to give candies to each child:
- Each child must have
at leastone candy. - Children with a
higher ratinggetmorecandies than their neighbors.
Return the minimum count of candies you require to distribute candies to the children.
Examples
- Example 1:
- Input: ratings =
[4, 2, 3, 4] - Expected Output:
8
- Input: ratings =
.....
.....
.....
Like the course? Get enrolled and start learning!