[scala] - quadratic recursion, quadratic array and indices
I am deeply concerned by the amount of attention given to Scala. Please submit your solutions and upvote.\n\n# Code\n\nobject Solution {\n\n  def countPairs(num
I am deeply concerned by the amount of attention given to Scala. Please submit your solutions and upvote.\n\n# Code\n```\nobject Solution {\n\n  def countPairs(nums: List[Int], target: Int): Int =\n    nums match {\n      case num :: tail => tail.count(_ + num < target) + countPairs(tail, target)\n      case Nil => 0\n    }\n}\n```\n\n```\nobject Solution {\n\n  def countPairs(nums: List[Int], target: Int): Int = {\n    val arr = nums.toArray\n    arr.indices.foldLeft(0) { (acc, i) =>\n      acc + ((i + 1) until nums.length).count(j => arr(i) + arr(j) < target)\n    }\n  }\n}\n```
['Scala']