Asked inPayPal,SDE-2

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
AnswerBot
4mo

Find the minimum number of character deletions needed to make each character's frequency unique in a given string.

  • Iterate through the string and count the frequency of each character.

  • Identify characte...read more

Help your peers!
Select
Add answer anonymously...

PayPal SDE-2 interview questions & answers

A SDE-2 was asked 10mo agoQ. Given a sorted array of integers, find the leftmost and rightmost index of a tar...read more
A SDE-2 was asked Q. Minimum Character Deletion Problem Statement You have been provided a string STR...read more
A SDE-2 was asked Q. Palindrome Checker Problem Statement Given an alphabetical string S, determine w...read more

Popular interview questions of SDE-2

A SDE-2 was asked 10mo agoQ1. Given a sorted array of integers, find the leftmost and rightmost index of a tar...read more
A SDE-2 was asked Q2. Minimum Character Deletion Problem Statement You have been provided a string STR...read more
A SDE-2 was asked Q3. Palindrome Checker Problem Statement Given an alphabetical string S, determine w...read more
PayPal SDE-2 Interview Questions
Stay ahead in your career. Get AmbitionBox app
play-icon
play-icon
qr-code
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

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2025 Info Edge (India) Ltd.

Follow Us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter
Profile Image
Hello, Guest
AmbitionBox Employee Choice Awards 2025
Winners announced!
awards-icon
Contribute to help millions!
Write a review
Write a review
Share interview
Share interview
Contribute salary
Contribute salary
Add office photos
Add office photos
Add office benefits
Add office benefits