Question: please use JAVA and the following method header to answer the question: public static long maxPoints(List elements) Given an array of integers, maximize points received

 please use JAVA and the following method header to answer the

please use JAVA and the following method header to answer the question:

public static long maxPoints(List elements)

Given an array of integers, maximize points received as you delete elements using the following rules: 1. Delete all elements of your chosen value. Add the sum of those values to your points. 2. Delete all elements equal to your chosen value plus or minus 1. No points are scored with these deletions, Once the entire array has been processed and there are no elements left, return the integer value of points calculated. For example, the given array is elements = (5, 6, 6, 4, 11]. First, delete 11 for a score of 11. Since there is no value 11-1 = 10 or 11 + 1 = 12, proceed with elements [5, 6, 6, 4). Choose to delete the two 6's for 12 more points. Delete any 6 1=5 and 6+1 = 7 elements: elements = (4). Delete the 4 for 4 points. The total score is 11 + 12 + 4 = 27. Function Description Complete the maxPoints function in the editor below. The function must return a long integer denoting the maximum number of points you can earn by performing deletions. maxPoints has the following parameter(s) elements: an array of integers Constraints 1sns 105 1

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!