#3147
Taking Maximum Energy From the Mystic Dungeon
specialist · 700 · lc medium +30 · 61% accepted · 588 likes · top 61%
Description
An array energy of n values represents magicians in a line (some values may be negative). Choose any starting index; you must collect that magician's energy, then jump to index (start + k), then (start + 2k), and so on until out of bounds. Return the maximum total energy collectible over all starting choices.
Code
1
2
3