Welcome to the daily solving of our PROBLEM OF THE DAY with Karan Mashru. We will discuss the entire problem step-by-step and work towards developing an optimized solution. This will not only help you brush up on your concepts of Strings but also build up problem-solving skills.
In this problem, we are given a string s of lowercase alphabets and a number k, the task is to print the minimum value of the string after removal of k characters. The value of a string is defined as the sum of squares of the count of each distinct character present in the string.
Example :
Input:
s = abccc, k = 1
Output:
6
Explaination:
We remove c to get the value as 12 + 12 + 22
Give the problem a try before going through the video. All the best!!!
Problem Link: https://www.geeksforgeeks.org/problems/game-with-string4100/1