An escape game requires that players solve various puzzles to obtain objects that will aid them in escaping. In one such
Posted: Tue May 24, 2022 8:32 am
An escape game requires that players solve various puzzles to obtain objects that will aid them in escaping. In one such puzzle, players are given an array of integers and a set of rules to follow in order. Here are the instructions given to the players: "Given an array of integer values, maximize the points earned using the following method: 1. Choose a value v. Delete all elements of that value and add their sum to the points. 2. Delete all elements equal to v+1 or v- 1 for no points. 3. Repeat steps 1 and 2 until there are no more elements in the array. Calculate the maximum number of points that can be achieved by following these rules for an array of values. Example elements = [5, 6, 6, 4, 11] Delete 11 for 11 points. Since there are no elements equal to 11-1= 10 or 11+1=12, proceed with the remaining elements: [5, 6, 6, 4]. Delete the two 6's for 12 more points. Delete any elements equal to 6-1=5 or 6+1=7. Then proceed with the remaining elements: [4]. Finally delete the 4 and add 4 points for total points 11 + 12+ 4 = 27. Function Description Complete the maxPoints function in the editor below.. maxPoints has the following parameter(s) int elements[n]: an array of integers Returns long int: the maximum number of points that can be earned