Company: LG ads
Difficulty: medium
2. Chocolate Game There are n children indexed from 0 to n-1 sitting in a circle. You are given a 0-indexed integer array, chocolate , where the child at index i will consume chocolate[i] chocolates. The teacher starts with k chocolates, which she provides to child at index 0, and child 0 consumes chocolate[0] chocolates and passes on the remaining to the next child. This will continue until the number of chocolates is less than the number required by the child, and this child will be unhappy. Along with the array chocolate , you're given another array initialValues where each value in the list is an independent query on the value of k (array chocolate is common for all queries). Return an array with the index of the unhappy child for each of the initial values. Function Description Complete the function chocolateGame in the editor below. Function Parameters: int chocolate[] : array of number of chocolates each child wants int initialValues[] : initial number of chocolates(k) for each