Skip to content

Instantly share code, notes, and snippets.

@feliperazeek
Created August 16, 2015 04:41
Show Gist options
  • Save feliperazeek/fb7252b5ff8c0bbc1b3b to your computer and use it in GitHub Desktop.
Save feliperazeek/fb7252b5ff8c0bbc1b3b to your computer and use it in GitHub Desktop.
object Solution {
def solution(A: Array[Int]): Int = {
val positive = new java.util.BitSet()
val negative = new java.util.BitSet()
A.foldLeft(0) { (current, i) =>
val duplicate = if (i < 0) (negative get i * -1)
else (positive get i)
duplicate match {
case true =>
current
case false =>
if (i >= 0) positive set i
else negative set i * -1
current + 1
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment