Return the max value of a List[Int]
if unique, otherwise return -1.
def maxIfUnique(li: List[Int]) = li.groupBy(_.intValue).maxBy(_._1)._2 match {
case x if x.size == 1 => x.head
case _ => -1
}
scala> val list = List(1, 2, 1) // 2 is max and is unique
scala> maxIfUnique(list)
res61: Int = 2
scala> val list = List(3, 3, 1) // 3 is max but not unique
scala> maxIfUnique(list)
res62: Int = -1