Unique Frequency Problem Statement
Given a string 'STR' with lowercase letters, determine the minimum number of deletions required to ensure that every letter in the string appears a unique number of times.
Example:
Input:
S = "aaBBccc"
Output:
1
Explanation:
The frequencies of the characters are {a:2, B:2, c:3}. Deleting one character from 'a' or 'B' adjusts the frequency so each is unique, resulting in frequencies 1, 2, and 3.
Input:
The first line of input contains a single integer 'T', denoting the number of test cases.
The first line of each test case contains a string 'STR'.
Output:
For each test case, print an integer indicating the minimum number of characters to delete such that each character frequency is unique.
Constraints:
- 1 <= T <= 10
- 1 <= |STR| <= 105
- Time limit: 1 sec
Note:
You are not required to print the output; it has already been taken care of. Implement the function accordingly.

AnswerBot
4mo
The task is to find the minimum number of deletions needed in a string to ensure each character appears a unique number of times.
Iterate through the string and count the frequency of each character
Tra...read more
Help your peers!
Add answer anonymously...
American Express Software Developer Intern interview questions & answers
A Software Developer Intern was asked Q. Left View of a Binary Tree Problem Statement Given a binary tree, your task is t...read more
A Software Developer Intern was asked Q. Minimum Number of Swaps to Sort an Array Find the minimum number of swaps requir...read more
A Software Developer Intern was asked Q. Maximum Non-Adjacent Subsequence Sum Given an array of integers, determine the m...read more
Popular interview questions of Software Developer Intern
A Software Developer Intern was asked Q1. Left View of a Binary Tree Problem Statement Given a binary tree, your task is t...read more
A Software Developer Intern was asked Q2. Minimum Number of Swaps to Sort an Array Find the minimum number of swaps requir...read more
A Software Developer Intern was asked Q3. Maximum Non-Adjacent Subsequence Sum Given an array of integers, determine the m...read more
>
American Express Software Developer Intern Interview Questions
Stay ahead in your career. Get AmbitionBox app


Trusted by over 1.5 Crore job seekers to find their right fit company
80 L+
Reviews
10L+
Interviews
4 Cr+
Salaries
1.5 Cr+
Users
Contribute to help millions
AmbitionBox Awards
Get AmbitionBox app

