# Problem 59

### 8 comments on “Problem 59”

• Chanchala singh

def lonely_integer(a):
result = 0
for i in a:
result ^= i ”’XOR OPERATION
A^A = 0
0^B = B So, for each pair of numbers the xor operation results in 0.
Since there is only one number that does not have a pair, the result is its lonly number,
since 0^b =b (or b^0 = b).”’
return result

n=int(input())
b = map(int,input().strip().split(” “))
print(lonely_integer(b)) 1
• Srimukhi

#include
int main()
{
int i,a,n,j;
scanf(“%d”,&n);
for(i=0;i<n;i++)
scanf("%d",&a[i]);
for(i=0;i<n;i++)
{
for(j=i+1;j<n;j++)
{
if(a[i]==a[j])
{
a[i]=0;
a[j]=0;
}
}
}
for(i=0;i<n;i++){
if(a[i]!=0)
printf("%d",a[i]);
}
}
in c 2
• HelpPrepInsta

Thanks for contributing the code Srimukhi 0
• vaishali

can i get the c code for this program?? 0
• HelpPrepInsta

Here is a C code for this problem
#include
#define MAX_SIZE 100

int main()
{
int arr[MAX_SIZE], freq[MAX_SIZE];
int size, i, j, count;

/* Input size of array and elements in array */
printf(“Enter size of array: “);
scanf(“%d”, &size);
printf(“Enter elements in array: “);
for(i=0; i 0
• Gunjan

sir,How to write this code in python 0
• HelpPrepInsta

You can solve this using list and compare function in python 0
• Tirtha

n = int(input(‘Enter the number of integers in the array’))
x = input().split()

def countUnique(x, n):
a = []
for i in range(n):
if x[i] in a:
continue
else:
a.append(x[i])

return len(a)

b = countUnique(x, n)
print(‘unique elements = {}’.format(b)) 2