Hallo Readers!!!
i 've attached my code for the hackerrank problem the lonley integer from algorithm section
the following code was compiled under jre8 environment.
import java.util.*;
import java.io.*;
public class cli {
public static void main(String[] args) {
int[] x = new int[100];
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
int result = 0;
if(n%2==1)
{
for (int i=0;i<n;i++) {
x[i]=sc.nextInt();
result ^= x[i];
}
System.out.println("result:"+result);
}
}
}
No comments:
Post a Comment