score:-1

Scala provides lots of library functions. Like, there is distinct function. You can directly call it.

scala> val array = Array(1,2,3,2,1,4)
array: Array[Int] = Array(1, 2, 3, 2, 1, 4)
scala> array.distinct
res0: Array[Int] = Array(1, 2, 3, 4)

Related Query

More Query from same tag