You are viewing a single comment's thread. Return to all comments →
Java, O(n)
public static int sansaXor(List<Integer> arr) { int n = arr.size(); if (n % 2 == 0) { return 0; } else { int result = 0; for (int i = 0; i < n; i += 2) { result ^= arr.get(i); } return result; } }
Seems like cookies are disabled on this browser, please enable them to open this website
Sansa and XOR
You are viewing a single comment's thread. Return to all comments →
Java, O(n)