title: How to fix "runtime error: reference binding to null pointer of type 'value_type' (stl_vector.h)" in leetcode?
body: <p>I am doing leetcode 376. Wiggle Subsequence.
  It went wrong when testing the first instance of input [1,7,4,9,2,5]. It showed that "Line 922: Char 34: runtime error: reference binding to null pointer of type 'value_type' (stl_vector.h)". Could anyone tell me what is going wrong? Thanks a lot!</p>
  
  <pre><code>class Solution {
  public:
      int wiggleMaxLength(vector&lt;int&gt;&amp; nums) {
          if(nums.size() &lt; 2){
              return nums.size();
          }
          std::priority_queue&lt;int&gt; big_heap;
          vector&lt;int&gt; flag;
          int result;
          int length = nums.size();
          for(int i = 0; i + 1 &lt; length; i++){
              if(nums[i+1] &gt; nums[i]){
              flag[i] = 1;
                  }
              else if(nums[i+1] &lt; nums[i]){
                  flag[i] = -1;
              }
              else{
                  flag[i] = 0;
              }
          }
          int count = 1;
          for(int i = 0; i + 2 &lt; length;i++){
              cout &lt;&lt;flag[i]&lt;&lt;endl;
              if(flag[i] + flag[i+1] == 0){
                  count ++;
              }
              else{
                  big_heap.push(count);
                  count = 1;
              }
          }
          big_heap.push(count);
          result = big_heap.top() + 1;
          return result;
  
      }
  };
  </code></pre>