Candy
135. Candy[H]
https://leetcode.com/problems/gas-station/
Description
There are N children standing in a line. Each child is assigned a rating value.
You are giving candies to these children subjected to the following requirements:
- Each child must have at least one candy.
- Children with a higher rating get more candies than their neighbors.
What is the minimum candies you must give?
Example 1:
1 | Input: [1,0,2] |
Example 2:
1 | Input: [1,2,2] |
Solution
https://leetcode.com/problems/candy/solution/
1 | class Solution(object): |
All articles in this blog are licensed under CC BY-NC-SA 4.0 unless stating additionally.
Comment





