title: Remove consecutive numbers from int array
body: <p>I want to remove consecutive repeated numbers from array like  if a sequence of 2 or more instances of the same integer repeated consecutively appears in that array, the sequence should be removed (see example below).</p>
  
  <pre><code>int[] array = {3, 1, 1, 2, 1, 4, 4, 4};
  </code></pre>
  
  <p>after removal of consecutive repeated numbers</p>
  
  <pre><code>(like 1,1 and 4,4,4)=&gt;{3,2,1}
  </code></pre>
  
  <p>thus i want to shift consecutive numbers to end and wanna use <code>Array.Resize()</code> function to resize array.
  i don't want complete code, approach will be fine.</p>
  
  <pre><code> static void RemoveRepeated(ref int[] array)
      {
          int count = 0; bool flag;
          for (int i = 0; i &lt; array.Length; i++)
          {
              flag = true;
              for (int j = i+1; j &lt; array.Length-1; j++)
              {
                  if (array[i] == array[j] )
                  {
  
                          int temp = array[j];
                          array[j] = array[j + 1];
                          array[j + 1] = temp;
                          if (flag)
                          {
                              count++;
                              flag = false;
                          }
                  }
              }
          }
          Array.Resize(ref array,array.Length-count);
      }
  </code></pre>