Description
Solutions
Maximize Score
📚RELATED PROBLEMS
You are given a string S
and an integer array of size N
. You need to maximize your score by performing the following operation multiple times until the string S
is empty:
Choose a substring from S
where all characters are identical.
Calculate the length of this substring, called size
.
Add the size
th element from the array arr
to your total score.
Remove the selected substring from S
.
Continue this process until the string S
is empty, and return the maximum possible score.
Example 1:
Input: S = "abbbac", arr = [2, 5, 3, 1, 7]
Output: 14
Explanation:
abbbac
->abac
->aac
->c
->""
5 + 2 + 5 + 2 = 14
Constraints:
🦡

Related Problems
Testcase
Result
Case 1
input:
output: