/*Given an array of integers, every element appears twice except for one. Find that single one.
Note:
Your algorithm should have a linear runtime complexity. Could you implement it without using extra memory?
*/
object SingleNumber {
def findSingle(arr: Array[Int]):Int = {
arr.toBuffer.filter(n => !((arr.toBuffer-=n) contains n))(0)
} //> findSingle: (arr: Array[Int])Int
//> arr : Array[Int] = Array(2, 2, 3, 3, 4, 4, 5, 5, 7, 7, 8, 8, 9, 9, 1)
val arr = Array(2,2,3,3,4,4,5,5,7,7,8,8,9,9,1)
val m = findSingle(arr) //> m : Int = 1
}