Skip to main content
3 of 7
added 105 characters in body
Jonah
  • 33.8k
  • 4
  • 40
  • 94

J, 40 29 19 18 bytes

1&|.^:(1 e.+/\)^:_

Try it online!

-11 after applying HyperNeutrino's scan sum idea

-10 after reading Leo's comment to HyperNeutrino: while(any of the cumulative sum is negative)(rotate by 1)

Jonah
  • 33.8k
  • 4
  • 40
  • 94