title: strange index issue for a simple vector
body: <p>I have one array like {7, 3, 1, 5, 2} for example. I want to get a max value from one index onwards, so the result should be like {7, 5, 5, 5, 2}. I just use a for loop like below. It throws strange heap overflow problem.</p>
  <pre><code>    int maxProfit(vector&lt;int&gt;&amp; prices) {
        vector&lt;int&gt; maxRight;
        int runningMax = 0;
        for(auto i=(prices.size()-1);i&gt;=0;i--){
          if(runningMax &lt; prices[i]){
            runningMax = prices[i];
          }
          maxRight.push_back(runningMax);
        }  
        maxRight.push_back(runningMax);
        std::reverse(maxRight.begin(), maxRight.end());
        ......
  </code></pre>
  <p>But if i change to the below code, it works. Isn't the below code the same as the above one? I just changed the comparison of the index i to 0 or to 1.</p>
  <pre><code>    int maxProfit(vector&lt;int&gt;&amp; prices) {
        vector&lt;int&gt; maxRight;
        int runningMax = 0;
        for(auto i=(prices.size()-1);i&gt;=1;i--){
          if(runningMax &lt; prices[i]){
            runningMax = prices[i];
          }
          maxRight.push_back(runningMax);
          
        }  
        if(runningMax &lt; prices[0]){
          runningMax=prices[0];
        }
        std::reverse(maxRight.begin(), maxRight.end());
        ......
  </code></pre>