Comments on: Programming Interview Questions 22: Find Odd Occurring Element
/2011/12/13/programming-interview-questions-22-find-odd-occurring-element/?utm_source=rss&utm_medium=rss&utm_campaign=programming-interview-questions-22-find-odd-occurring-element
Information Retrieval and Machine LearningMon, 23 Jan 2012 19:14:24 +0000hourly1http://wordpress.org/?v=3.3By: Arden
/2011/12/13/programming-interview-questions-22-find-odd-occurring-element/#comment-759
ArdenWed, 14 Dec 2011 09:04:00 +0000/?p=883#comment-759Here's the C/C++ code:
<pre lang="cpp" escaped="true">
int getOdd(int *arr, int size)
{
int result=0;
for(int i=0; i<size; i++)
{
result^=arr[i];
}
return result;
}
</pre>
And here's the python reference for reduce: http://docs.python.org/library/functions.html#reduceHere’s the C/C++ code:
int getOdd(int*arr, int size){int result=0;for(int i=0; i<size; i++){
result^=arr[i];}return result;}
And here’s the python reference for reduce:
]]>By: umar
/2011/12/13/programming-interview-questions-22-find-odd-occurring-element/#comment-758
umarWed, 14 Dec 2011 08:52:10 +0000/?p=883#comment-758def getOdd(arr):
return reduce(lambda x, y: x^y, arr)
Can u Write above algo in C++.
what is reduce?def getOdd(arr):
return reduce(lambda x, y: x^y, arr)