Children with same rating next to each other

If I have input array: 3 6 6 8
The expected result is 6, but my assumption is distribution like this:
Ranks: 3 6 6 8
Candies: 1 2 2 3
Which gives 8 candies.
Only possible explanation I see to get 6 candies is:
Ranks: 3 6 6 8
Candies: 1 2 1 2
Which is not logical distribution, but I guess it does satisfy the condition…
This should be in the notes.

Agree, this is totally idiotic without explaining this.

Thanks… I have solved problem because of your comment.
I was solving the problem with same logic if next to each other and same rating I am giving the same candies.

They should add this point in question.

Click here to start solving coding interview questions