Problem · Array

Maximize Power Values Sum 🪴

Learn this problem
MediumGoogleOA
See Google hiring insights

Problem statement

You are provided with an array containing N power values, each representing a specific power level. Additionally, a value K is given, signifying that choosing a power value X excludes any other power values within the range of X-K to X+K exclude X itself. Your objective is to determine the maximum sum achievable by selecting the optimal power values.

Function

maximizePowerValuesSum(powerValues: int[], k: int) → int

Examples

Example 1

powerValues = [1, 2, 3, 10, 9]k = 2return = 13
No explanation is provided for now 🐡

Constraints

Unknown for now 😉

More Google problems

drafts saved locally
public int maximizePowerValuesSum(int[] powerValues, int k) {
    // write your code here
}
powerValues[1, 2, 3, 10, 9]
k2
expected13
checking account