I didn't understand well the question

for the case of [ 5 5 4 3 2 1] I was expected the children will be given candies with these numbers : [1 2 3 4 5 1]
which makes a sum of 16 and not 15 … I’m missing sth I guess :s
thanks for help

Click here to start solving coding interview questions