Minimum Deletion Cost To Avoid Repeating Letters

medium
Given a string s and an array of integers cost where cost[i] is the cost of deleting the ith character in s.

Return the minimum cost of deletions such that there are no two identical letters next to each other.

Notice that you will delete the chosen characters at the same time, in other words, after deleting a character, the costs of deleting other characters will not change.

 

Input Format

Input and output are managed for you. Just complete the function.

Output Format

Input and output are managed for you. Just complete the function.

Constraints

s.length == cost.length
1 <= s.length, cost.length <= 10^5
1 <= cost[i] <= 10^4
s contains only lowercase English letters.

Notice

NA

Example

Input
abaac
5
1 2 3 4 5
Output
3
Previous
Area Of Circle
Next
Replace All ?'s To Avoid Consecutive Repeating Characters

Related Questions