4 ms·
Not the answer to your question, but: > I duplicate the array and remove the first item in the duplicated array, append the last entry of the original array to
by dataflow 3y ago
Not the answer to your question, but:
> I duplicate the array and remove the first item in the duplicated array, append the last entry of the original array to the duplicate in order for them to be equal in length.
I assume/hope this is only what you're doing logically, not physically?
Otherwise you might as well just compute the length using n - 1 points from the existing array, then do the remaining portion manually and add it to the existing sum. That would avoid the copying of the whole array.