scala pattern match
scala\nobject Solution {\n  def removeAlmostEqualCharacters(word: String): Int =\n    def f(l: List[Char], acc: Int): Int = l match {\n      case _ :: Nil | Nil
```scala\nobject Solution {\n  def removeAlmostEqualCharacters(word: String): Int =\n    def f(l: List[Char], acc: Int): Int = l match {\n      case _ :: Nil | Nil => acc\n      case a::b::t if (a-b).abs<=1 => f(t,acc+1)\n      case _ :: t => f(t,acc)\n    }\n    f(word.toList,0)\n}\n```
['Linked List', 'String', 'Greedy', 'Scala']