List replication problem from Hacker rank
Use scala.collection.generic.SeqFactory.fill(n:Int)(elem: =&gt;A) instead of your self written one:

def listReplication(num:Int,arr:List[Int]):List[Int] = {
      arr.flatMap(each =&gt; List.fill(num)(each))
}


Also note that listReplication is a nice candidate for generics:

def listReplication[A](num:Int,arr:List[A]):List[A] = {
      arr.flatMap(each =&gt; List.fill(num)(each))
}


That way you can also handle lists that contain something else than Int.