Optimized the solution, cut runtime from approximately 3 seconds to about 1.5. got rid of final loop in favor of running sum.