title: Error while finding the running sum of an array in C++ using vectors
body: <p>Why am i getting this error, while finding the running sum of an array in c++?</p>
  <pre><code>Line 1034: Char 34: runtime error: addition of unsigned offset to 0x6020000000b0 overflowed to 0x6020000000ac (stl_vector.h)
  SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /usr/bin/../lib/gcc/x86_64-linux-gnu/9/../../../../include/c++/9/bits/stl_vector.h:1043:34&quot;.
  </code></pre>
  <p>the code is:</p>
  <pre class="lang-cpp prettyprint-override"><code>    class Solution {
      public:
          vector&lt;int&gt; runningSum(vector&lt;int&gt;&amp; nums) {
            vector&lt;int&gt; temp(nums.size());
              nums[0]=temp[0];
              for(int i=0;i&lt;nums.size();i++){
                  temp[i]=temp[i-1]+nums[i];
              }
                return temp;
          }
      };
  </code></pre>