Say we have an array with some numbers in it, and we are given a value d (where d >= 1) that dictates a certain required index. How would we find the largest sum of values bounded by d. Here is an example:
arr = [3000, 4000, 2000, 2500, 3500, 5000]
d = 3
Would return 4000 + 5000 = 9000 (since there is at least a distance of 3 between these two numbers). But in this case:
arr = [3000, 4000, 2000, 2500, 3500, 5000]
d = 2
Would return 4000 + 2500 + 5000 = 11500.
edit: More explanation - We need to find the largest possible sum in an array. The only trick is that we cannot include numbers that are less than d index away. In the second example we could easily just sum all the numbers to get the largest value, but since we are bounded by d = 2, we have to pick a combination where numbers are not < distance 2 away. Another example might include 3000 + 2500 + 5000 = 10500. If you look at my second solution 11500 > 10500, therefore this is not the optimal answer