I am trying to solve a beginner problem but can't reach the solution:
If any duplicates in list, return true, else false. Empty lists considered.
def duplicates(a: List[Int]): Boolean = {
case Nil => false
case x :: xs =>
if(xs.contains(x)) true else false
}
But this doesn't work. And it's not recursive. It's just something where I wanted to start but I'm stuck. Please kindly help and try to avoid non-beginner solutions if reasonable.