You are given an integer array energy and an integer k.
There is a sequence of magicians in a line, where energy[i] represents the energy provided by the magician at index i. You may choose any starting magician and absorb their energy. After absorbing energy from magician i, you must jump to magician i + k and absorb their energy. This process continues, jumping by k indices each time, until the next jump goes beyond the bounds of the array.
Return the maximum total energy you can collect.
Constraints:
energy.length
energy[i]
k energy.length
You are given an integer array energy and an integer k.
There is a sequence of magicians in a line, where energy[i] represents the energy provided by the magician at index i. You may choose any starting magician and absorb their energy. After absorbing energy from magician i, you must jump to magician i + k and absorb their energy. This process continues, jumping by k indices each time, until the next jump goes beyond the bounds of the array.
Return the maximum total energy you can collect.
Constraints:
energy.length
energy[i]
k energy.length