Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

OCA Oracle Database SQL Exam Guide Exam 1Z0-071

Authors: Steve O'Hearn

1st Edition

1259585492, 978-1259585494

More Books

Students also viewed these Databases questions

Question

=+What does this say for the future of the business case for CSR?

Answered: 1 week ago