Gr-affable icon indicating copy to clipboard operation
Gr-affable copied to clipboard

Redundant Loop

Open harpoonix opened this issue 3 years ago • 1 comments

https://github.com/harpoonix/Gr-affable/blob/3845733a922b0ea0a8cde7bb4b8dd566044a4d07/Symphony/subarray_sum.cpp#L11-L16

We don't need to calculate the sum of the subarray again when the end shifts from j to j+1. We can simply add array[j+1] to the previous sum. Saves computation.

harpoonix avatar Oct 10 '22 13:10 harpoonix

Raised PR https://github.com/harpoonix/Gr-affable/pull/29

pranavyatnalkar avatar Oct 14 '22 07:10 pranavyatnalkar