Question: write in java 8 Jesse loves cookies. He wants the sweetness of all his cookies to be greater than value K. To do this, Jesse
write in java 8





Jesse loves cookies. He wants the sweetness of all his cookies to be greater than value K. To do this, Jesse repeatedly mixes two cookies with the least sweetness. He creates a special combined cookie with: sweetness= (1x Least sweet cookie + 2x 2nd least sweet cookie). He repeats this procedure until all the cookies in his collection have a sweetness > K. You are given Jesse's cookies. Print the number of operations required to give the cookies a sweetness > K. Print 1 if this isn't possible. Input Format The first line consists of integers N, the number of cookies and K, the minimum required sweetness, separated by a space. The next line contains N integers describing the array A where A is the sweetness of the ith cookie in Jesse's collection. Constraints 1
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
