title: How to free low heap memory in a function？
body: <pre><code> bool containsDuplicate(vector&lt;int&gt;&amp; nums) {
      int n=nums.size();
      int* counter=new int[n];
      for(int i=0;i&lt;n-1;++i){
          ++counter[i];
      }
      for(int i=0;i&lt;n;++i){
          if(int i&gt;1) return true;
      }
      return false;
  }
  </code></pre>
  <p>As you can see,I applied for a heap space'counter';
  So,I want know if I need to free the heap memory,how to free the heap memory? Thank you.</p>