Forked from feliperazeek/CodilityOddOccurrencesInArray.scala
Created
July 31, 2019 20:57
-
-
Save royki/b62acb12f9a9e08c9c4e045c525870e7 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