"Children with a higher rating get more candies than their neighbors." So, if we

"Children with a higher rating get more candies than their neighbors."
So, if we have ratings like 1 2 10 2 4 2 5, then we can assign same number of candies to both 10 and 4 ?

yea you can but be sure that mentioned contion will not be violated

How can we assign the same number of candies to both 10 and 4? The candies assignment has to be [1,2,3,1,2,1,2]. No?

Click here to start solving coding interview questions