title: Array of unique elements but with a condition-
body: <p>I have an array of integers (NSMutable array to be exact), now i want the array to have unique elements, but there is a catch.</p>
  
  <p>Condition-1. If there are 2 (even number of )elements that are similar then both the elements need to be deleted.
  Condition-2.  If there are 3(odd number of) elements then only 1 element shall remain in the array.</p>
  
  <p>am having a bit of a problem trying to solve it.
  I have tried to loop around the array with 2 temporary variables</p>
  
  <pre><code> for(int i =1;i&lt;[tagArray count];i++){
      int temp1 = [[tagArray objectAtIndex:i] intValue];
      int temp2 = [[tagArray objectAtIndex:i-1] intValue];
      if(temp1==temp2){
  
          [tagArray removeObjectIdenticalTo:[tagArray objectAtIndex:i]];
          [tagArray removeObjectAtIndex:i];
          NSLog(@"%@",tagArray);
      }
  }
  </code></pre>
  
  <p>This code works but, when there are a lot of elements in the array the output i get is not the desired one.
  P.S- the array is already being filled up randomly so i took the liberty of sorting it first.</p>
  
  <p>1 more thing. please dont say abt set, i want unique elements but when i use SET see condition1 and 2. i cant perform those.</p>