hi, let Avik connect you.
** You can give your thought about this content and request modifications if needed from Ask For Modifications page. Thank You.
** You can check all the posts on the Posts page.
** More about me in the About Me section.
One Odd Occurring
Problem: One Odd Occurring
Problem Link:
Companies Asked: Infosys, Cerner
Approach:
Traverse through the given array.
Take the XOR of each element.
Return the result.
Time and Space Complexity:
Time Complexity: O(N)
Space Complexity: O(1)
Code [C++]
Code [C++]
#include <bits/stdc++.h>
int missingNumber(int n, vector<int> &arr){
int num = 0;
for(int i=0; i<n; i++){
num ^= arr[i];
}
return num;
}