Problem Brief
Minimum Operations to Remove Characters in Frequency Order (Find Min Deletions :)
NEW GRADOA
See Amazon online assessment and hiring insights
(Look into LC 664. Strange Printer may help :)
Given a string, determine the minimum number of operations (deletions) required to make the string empty.
You can perform the deletion operation as many times as you prefer::
Function Description
Complete the function minimumOperationsToRemove in the editor.
minimumOperationsToRemove has the following parameter:
String s: the string to be processed
Returns
int: the minimum number of operations required
1Example 1
Input
s = "abaca"
Output
3
Explanation
Pick s = 1: remove "b" -> "aaca"
Pick s = 1: remove "c" -> "aaa"
Pick s = 3: since all the a's are together remove all a's at once. Now it is empty.
We can make the input string empty in just 3 operations. So, we return 3 as the answer.