Problem Submissions Solution

Game with String

Difficulty: Medium

Acceptance: %

Points: 30.00

Given a string str consisting of lowercase alphabets and a number k, the task is to find the minimum possible value of the string after removing k characters. The value of a string is defined as the sum of the squares of the frequencies of each distinct character in the string. Your goal is to return the minimum value that can be achieved after removing exactly k characters.

Topics

Companies

Articles

Examples:

Expected Time Complexity: O(n+klog(p))

Expected Auxiliary Space: O(n)

Constraints:
  • 0 <= k <= |string length| <= 5*10^4
Companies:
Amazon Walmart Adobe
Topics:
Heap
Locked Content
Access Restricted: Please Login to access the code editor and test cases.