Created
January 15, 2019 09:35
-
-
Save kanahaiya/e75d31c0012eded81241ae5f6b983d92 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @author Kanahaiya Gupta | |
* | |
*/ | |
public class LonelyInteger { | |
static int lonelyinteger(int[] a) { | |
int result = 0; | |
for (int i = 0; i < a.length; i++) { | |
result ^= a[i]; | |
} | |
return result; | |
} | |
public static void main(String[] args) { | |
Scanner in = new Scanner(System.in); | |
int res; | |
int _a_size = Integer.parseInt(in.nextLine()); | |
int[] _a = new int[_a_size]; | |
int _a_item; | |
String next = in.nextLine(); | |
String[] next_split = next.split(" "); | |
for (int _a_i = 0; _a_i < _a_size; _a_i++) { | |
_a_item = Integer.parseInt(next_split[_a_i]); | |
_a[_a_i] = _a_item; | |
} | |
res = lonelyinteger(_a); | |
System.out.println(res); | |
in.close(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment