scala solution
```scala []
object Solution {
  def countMentions(numberOfUsers: Int, events: List[List[String]]): Array[Int] = {
    val (as,es) = events.partition(a => a(2)=="ALL")
    val all = as.size
    val (ans,offs) = (Array.fill(numberOfUsers)(all),Array.fill(numberOfUsers)(-1))
    es.map{
      case List(typ,tm,str) =>
        lazy val str1 = if(str == "HERE") Array(-1) else str
        lazy val ids =
          if(str.isEmpty) List.empty[Int]
          else if(str == "HERE") List(-1)
          else str.filterNot(_.isLetter).split(" ")
            .flatMap(s => Option.when(s.nonEmpty)(s.toInt)).to(List)
        (typ.head, tm.toInt, ids)
      case _ => ???
    }.sortBy{case (typ,tm,_) => (tm,-typ)}
    .zipWithIndex.foreach{case ((typ,tm,ids),i) =>
      lazy val ids1 =
        if(!ids.headOption.contains(-1)) ids else
          offs.zipWithIndex.collect{case (off,i) if off<=tm => i}.toList
      if(typ == 'M') ids1.foreach(ans(_) += 1)
      else ids1.foreach(offs(_)  = tm+60)
    }
    ans
  }
}
```
['Sorting', 'Simulation', 'Scala']