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

Popular posts from this blog

yii2 - Yii 2 Running a Cron in the basic template -

asp.net - 'System.Web.HttpContext' does not contain a definition for 'GetOwinContext' Mystery -

mercurial graft feature, can it copy? -