Just brutal force O(n2) for such boring question
scala\n  def countSubstrings(s: String, t: String): Int = {\n\n    val sl = s.length\n    val tl = t.length\n    (0 until sl)\n      .map(i => {\n        (0 unt
```scala\n  def countSubstrings(s: String, t: String): Int = {\n\n    val sl = s.length\n    val tl = t.length\n    (0 until sl)\n      .map(i => {\n        (0 until tl)\n          .filter(s.charAt(i) != t.charAt(_))\n          .map(j => {\n            var a = i + 1\n            var b = j + 1\n            while (a < sl && b < tl && s.charAt(a) == t.charAt(b)) { a += 1; b += 1 }\n            val right = a - i - 1\n            a = i - 1\n            b = j - 1\n            while (a >= 0 && b >= 0 && s.charAt(a) == t.charAt(b)) { a -= 1; b -= 1 }\n            val left = i - a - 1\n            right * left + right + left + 1\n\n          })\n          .sum\n\n      })\n      .sum\n\n  }\n```
[]