title: Given an array of 2n elements of which n are similar and n are different
body: <p>Given an array of 2n elements of which n elements are same and the remaining n elements are all different. Write a C program to find out the value which is present n times in the array</p>
  
  <p>I thought in the following way-
  compare a[i] and a[i+1] and
  compare a[i] and a[i+2]
  and return element</p>
  
  <p>this will run in O(n) time..can anyone give better solution?</p>
  
  <p>I was going through some solutions where it is saying like this-</p>
  
  <blockquote>
    <ol>
    <li>Declare two variables a) count variable to keep track of count of majority element.</li>
    <li>Majority element.</li>
    <li>Do a for loop and repeat following steps 4-6 until end of array is reached.</li>
    <li>if current array element equals majority element, increment count</li>
    <li>else, if count is 0, update majority element with current array element and increment count.</li>
    <li>else if count is not 0 then decrement count.</li>
    <li>Do another for loop and count the number of occurrences of majority element in the array, if it's half the array size then we have found the majority element, else there's no majority element.</li>
    </ol>
  </blockquote>