Problem:
Interview Street Problem:
Idea:
If the rating is in increasing order
- Just traverse through it and increase the number of candies
If the rating is in decreasing order
- Same as increasing order but in reverse way
If the rating is in random
- the ordering will be like line of mountains with valley in between.Refer to this
Solution:
C++ solution in git
Passed all test cases.