[scala] - sliding window, no index, foldLeft, recursion
I am deeply concerned by the amount of attention given to Scala. Please upvote and submit your solutions.\n\n# Code\nscala\nobject Solution {\n  import scala.co
I am deeply concerned by the amount of attention given to Scala. Please upvote and submit your solutions.\n\n# Code\n```scala\nobject Solution {\n  import scala.collection.immutable.Queue\n\n  def numberOfSubstrings(s: String, k: Int): Int =\n    s.foldLeft(Queue.empty[Char], Map.empty[Char, Int], 0) { case ((queue, map, acc), c) =>\n      val (nQueue, nMap) = (queue :+ c, map.updated(c, map.getOrElse(c, 0) + 1))\n      (nQueue, nMap, go(nQueue, nMap, k) + acc)\n    }._3\n\n  private def go(q: Queue[Char], map: Map[Char, Int], k: Int): Int =\n    if (map.exists(_._2 >= k)) 1 + go(q.tail, map.updated(q.head, map(q.head) - 1), k) else 0\n}\n```
['Scala']