#3784

Minimum Deletion Cost to Make All Characters Equal

medium · 55% accepted · 87 likes · top 48%

array · hash table · string · enumeration

Description

You are given a string s of length n and an integer array cost of the same length, where cost[i] is the cost to delete the ith character of s.

You may delete any number of characters from s (possibly none), such that the resulting string is non-empty and consists of equal characters.

Return an integer denoting the minimum total deletion cost required.

Solution