Problem in understanding the candy question


  • 0
    P

    There are N children standing in a line. Each child is assigned a rating value.
    You are giving candies to these children subjected to the following requirements:
    Each child must have at least one candy.
    Children with a higher rating get more candies than their neighbors.

    Here the rating is passed as a parameter to the function.
    But where is the information about children having the candies?
    I am referring to this particular line

    Each child must have at least one candy.

    How do we decide which child has how many candies initially?


  • 0
    D

    It's given that each child have at least one candy.which means lowest priority children will get only one candy it's neighbors will get +1 or same number of candy it will depend on their priority.


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.