c++ - sum of all the elements in an array in less than O(n) -
i tried adding places , odd places in loop add both final answer making complexity o(n/2) need better way
you manage array , update sum when there changes. shifts time modifying operations , technically calculate (or not) sum in 0 time.
Comments
Post a Comment