Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save royki/b62acb12f9a9e08c9c4e045c525870e7 to your computer and use it in GitHub Desktop.
Save royki/b62acb12f9a9e08c9c4e045c525870e7 to your computer and use it in GitHub Desktop.
Codility OddOccurrencesInArray
object Solution {
def solution(A: Array[Int]): Int = {
val N = A.size
if (N < 1 || N > 1000000) sys.error(s"Invalid array size: $N")
A.foldLeft(0) { (current, i) =>
i ^ current
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment