Problem · String
Minimum Operations to Remove Characters in Frequency Order (Find Min Deletions :)
See Amazon 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::
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
Examples
01 · Example 1
s = "abaca" return = 3
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.
More Amazon problems
- Count Promotional PeriodsOA · Seen Jun 2026
- Find Maximum Total Amount (SDE I, Fungible :)Seen Jun 2026
- Get Minimum AmountOA · Seen Jun 2026
- Find Minimum CostOA · Seen Jun 2026
- Get Smallest Base SegmentOA · Seen Jun 2026
- Select Least Resource TasksOA · Seen Jun 2026
- Product Category Group SizesPHONE SCREEN · Seen May 2026
- Count Connected ComponentsPHONE SCREEN · Seen May 2026
public int minimumOperationsToRemove(String s) {
// write your code here
}
s"abaca"
expected3
sign in to submit