You are viewing a single comment's thread. Return to all comments →
Beautiful and fast Java solution:
public class Solution { private static int lonelyInteger(int[] a) { int value =0; for(int i=0; i<a.length; i++){ value ^= a[i]; } return value; } public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); int[] a = new int[n]; for (int i = 0; i < n; i++) { a[i] = in.nextInt(); } System.out.println(lonelyInteger(a)); } }
Seems like cookies are disabled on this browser, please enable them to open this website
Lonely Integer
You are viewing a single comment's thread. Return to all comments →
Beautiful and fast Java solution: