Company: Wells_Frago_IIT_kgp
Difficulty: medium
Question 1 Problem Description You are given an array initialEnergy of size n, where each element represents the starting energy of a particle in space. The energy of a particle is reduced by a value called the barrier. If the energy becomes less than zero, it is set to zero. Your task is to find the maximum possible value of the barrier such that the total of all finalEnergy values is greater than or equal to a given threshold th. Complete the function getMaxBarrier in the editor with the following parameter(s): - int initialEnergy[n]: the initial energies of the particles - int th: the threshold Returns: - int: the maximum integer value of the barrier such that the sum of energies of all the particles is greater than or equal to th Examples Example 1: Input: n = 5, initialEnergy = [4, 8, 7, 1, 2], th = 9 Test barrier values of 0 through 4. barrier initialEnergy - barrier sum of final energies --------------------------------------------------------- 0 4 8 7 1 2 22 1 3 7 6 0 1 17 2 2