There are n children standing in a line. Each child has a rating value. You must give at least 1 candy per child. Children with higher ratings than adjacent neighbors must get more candies. Return the minimum total candies.
Input: Integer array ratings of length n.
Output: Integer — minimum total candies.
Input: [1,0,2]
Output: 5
Explanation: [2,1,2]. Total=5.Input: [1,2,2]
Output: 4
Explanation: [1,2,1]. Total=4.Input: [1,2,3,4,5]
Output: 15
Explanation: [1,2,3,4,5]. Total=15.n==ratings.length1<=n<=2*10^40<=ratings[i]<=2*10^4