+ 1
How to check if an array of integers contain a duplicate number
7 ответов
+ 2
I would like to see your try first, how about that?
+ 1
Hint:
* Sort the array.
* Save the first element into a variable, assume it as previous value.
* Iterate through it beginning from the second element.
* During iteration see through it, whether the current element value equals the previous one.
* If current value equal to previous value then you know that array contains a duplicate.
* If current value not equal to the previous one then assign current value to previous value and continue with next element.
+ 1
Tq so much Ipang..😇 But can you please send me the code too🙏
+ 1
Okk
+ 1
Plz check my post
+ 1
Tq so much Hima
0
take xor (^) with every element
if the result is a non-zero value then your array contains duplicate value/values
if it is 0 then it doesn't.