there n child stand line each child assign rating value give integer array ratingsyou give candy child subject follow requirementsEach child candychildren high rating candy neighborsreturn minimum number candy need distribute candy child example 1input rating 102output 5explanation you allocate second child 2 1 2 candy respectivelyexample 2input rating 122output 4explanation you allocate second child 1 2 1 candy respectivelythe child get 1 candy satisfie condition Constraintsn ratingslength1 n 2 1040 ratingsi 2 104