HackerRank Maximum Score

HackerRank Maximum Score

There are several books placed in the HackerStudy
library. One of those books on mathematics
described an interesting problem that a
mathematician wishes to solve.
For an array arr of n integers, the mathematician
can perform the following move on the array:
1. Choose an index i (0 si < length(arr)) and add arr[i] to their scores. # Complete the 'getMaximumScore' function below. # The function is expected to return a LONG_INTEGER. # The function accepts following parameters: INTEGER _ARRAY arr 2. INTEGER k def getMaximumScore(arr, k) : # Write your code here 2. Discard either the left partition (i.e. arr[0, 1,... / - 17) or the right partition (i.e. arr[i + 1, i + 2,….. length(arr) -1). The partition discarded can be empty too. The selected partition then becomes the new value of arr and is used for subsequent operations. Starting with an initial score of O, the mathematician wishes to find the maximum achievable score after k moves. Consider n = 6, arr = [4, 6,-10, -1, 10, -201, and k = 4 One optimal way the mathematician can perform the moves is as follows.