Last active
July 31, 2019 20:57
-
-
Save feliperazeek/1958ca5944ce8f24bec0 to your computer and use it in GitHub Desktop.
Codility OddOccurrencesInArray
This file contains 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
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