← All problemsSign in

3545. Minimum Deletions for At Most K Distinct Characters

LeetCodeHash TableStringGreedySortingCountingOpen on judge ↗

You are given a string s consisting of lowercase English letters, and an integer k. Your task is to delete some (possibly none) of the characters in the string so that the number of distinct characters in the resulting string is at most k. Return the minimum number of deletions required to achieve this. Example 1: Input: s = "abc", k = 2 Output: 1 Explanation: - s has three distinct chara

HINT LADDERno hints yet
L1 Observation
L2 Technique
L3 Approach
L4 Pseudo-code
🔒
L5 Full solution
L5 unlocks only if you insist twice
solution.cppC++17

CodeSearch Tutor

Hints, not spoilers — it won’t hand over the full solution unless you insist.

voice by Sarvam AI

Sign in to chat with the tutor and save your progress.

Sign in to start