Sunday, May 15, 2016

Codility Odd Occurrences In Array Solution C#.Net

Codility Odd Occurrences In Array Solution C#.Net

[ Find value that occurs in odd number of elements.]

Solution:

public int solution(int[] A)
{
   int unMatchNumber = A[0];
   for (int i = 1; i < A.Length; i++)
   {
        unMatchNumber = unMatchNumber ^ A[i];
   }
 return unMatchNumber;
}


And here goes, got 100%. :) 






No comments:

Post a Comment