Question: Use Java to solve the problem. Alice is a kindergarten teacher. She wants to give some candy to the children in her class. The children
Use Java to solve the problem.


Alice is a kindergarten teacher. She wants to give some candy to the children in her class. The children sit in a single row, and each child has a numeric score that reflects his or her performance in the class. Alice wants to give at least 1 piece of candy to each child. If two children sit next to each other, then the one with the higher score must get more pieces. Alice wants to save money, so she needs to minimize the total number of pieces of candy. Your task is to complete function distributeCandies which takes an integer array as a parameter representing the performance score of N children Input Format The locked stub code in your editor reads the following input from stdin and passes it to your function The first line of the input is an integer N, the number of children in Alice's class N subsequent lines contains an integer that indicates the performance score of each child
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
