title: How to remove duplicated items in a sorted vector
body: <p>I currently have a <code>vector&lt;int&gt; c</code> which contains <code>{1,2,2,4,5,5,6}</code>
  and I want to remove the duplicated numbers so that <code>c</code> will have
  <code>{1,4,6}</code>. A lot of solutions on the internet seem to just remove one of the duplicates, but I'm trying to remove all occurrences of the duplicated number.</p>
  <p>Assume <code>c</code> is always sorted.</p>
  <p>I currently have</p>
  <pre class="lang-c++ prettyprint-override"><code>#include &lt;iostream&gt;
  #include &lt;vector&gt;
  
  int main() {
    vector&lt;int&gt; c{1,2,2,4,5,5,6};
    for (int i = 0; i &lt; c.size()-1; i++) {
      for (int j=1; j&lt;c.size();j++){
        if(c[i] == c[j]){
           // delete i and j? 
        }
      }
    }
  }
  </code></pre>
  <p>I tried to use two for-loops so that I can compare the current element and the next element. This is where my doubt kicked in. I'm not sure if I'm approaching the problem correctly.</p>
  <p>Could I get help on how to approach my problem?</p>