Minimum Character Deletion Problem Statement
You have been provided a string STR
. Your task is to find and return the minimum number of characters that need to be deleted from STR
so that each character's frequency in the string is unique.
Example:
Input:
STR = "aaBBccc"
Output:
1
Explanation:
The frequency of characters: {a:2, B:2, c:3}. Both 'a' and 'B' have the same frequency of 2. By removing one character, either 'a' or 'B', their frequencies become different resulting in {1, 2, 3}, which are all unique.
Input:
"T" - Number of test cases.
For each test case: A string "STR".
Output:
An integer for each test case, representing the minimum number of deletions required to make all character frequencies in 'STR' unique.
Constraints:
- 1 ≤ T ≤ 10
- 1 ≤ |STR| ≤ 105
Be the first one to answer
Add answer anonymously...
Top PayPal SDE-2 interview questions & answers
Popular interview questions of SDE-2
Stay ahead in your career. Get AmbitionBox app
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+
Reviews
4 L+
Interviews
4 Cr+
Salaries
1 Cr+
Users/Month
Contribute to help millions
Get AmbitionBox app