title: Runtime error: addition of unsigned offset
body: <p>I was solving a question on Leetcode(Trapping rain water) and i wrote my solution which had been tested on my local machine as well as on GeeksForGeeks where it passed all TC's. the code is:</p>
  
  <pre><code>    int trap(vector&lt;int&gt;&amp; height) {
          int size = height.size();
          int i,units;
  
          vector&lt;int&gt; l(size),r(size);
          l[0] = height[0];
          r[size-1] = height[size-1];
  
          for(i=1; i&lt;size; i++){
              l[i] = max(height[i-1],l[i-1]);
          }
  
          for(i=size-1; i&gt;=0; i--){
              r[i-1] = max(r[i],height[i]);
          }
  
          for(i=0; i&lt;size; i++){
              if((min(l[i],r[i]) == 0) || (min(l[i],r[i])-height[i]&lt;0))
                  continue;
              else{
                 units +=min(l[i],r[i])-height[i];
              }
          }
          return units;
      }
  </code></pre>
  
  <p>This is the only part i had to edit. And upon running it i'm getting the following error </p>
  
  <pre><code>Line 928: Char 34: runtime error: addition of unsigned offset to 0x6040000000d0 overflowed to 0x6040000000cc (stl_vector.h)
  SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /usr/bin/../lib/gcc/x86_64-linux-gnu/8/../../../../include/c++/8/bits/stl_vector.h:933:34
  </code></pre>
  
  <p>I need some help finding where I'm experiencing a buffer overflow. Cheers in advance.</p>