There are n children in a line each with a rating. Distribute candies so each child gets at least one, and any child with a higher rating than an immediate neighbor gets more candies than that neighbor. Return the minimum total candies.
Input: An integer array of ratings.
Output: Integer — minimum candies.
Input: [1,0,2]
Output: 5
Explanation: Candies [2,1,2]=5.Input: [1,2,2]
Output: 4
Explanation: Candies [1,2,1]=4.Input: [1]
Output: 1
Explanation: One child.0<=n<=2*10^40<=ratings[i]<=2*10^4