scala solution
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nobject Solution {\n  def minimumDeletions(word: String, k: Int): Int = {\n    val freq = word.groupBy(identity).view.mapValues(_.size).values\n    if(freq.size == 1 || freq.min + k >= freq.max) return 0\n    (freq.min + k to freq.max).foldLeft(Int.MaxValue)((acc, cur) =>{\n      (freq.filter(_ < cur - k).sum + freq.filter(_ > cur).map(_ - cur).sum) min acc\n    })\n  }\n}\n```
['Scala']