commit cc659873f5697b32e5a17eeca6cef8d7116216c4
parent 03a9a893c3ab5d7dd12683ef1be7c21e4fa4fffb
Author: Dimitrije Dobrota <mail@dimitrijedobrota.com>
Date: Mon, 29 Jan 2024 21:26:33 +0000
1 Random Problem
Diffstat:
2 files changed, 20 insertions(+), 0 deletions(-)
diff --git a/Problems/2606.cpp b/Problems/2606.cpp
@@ -0,0 +1,19 @@
+class Solution {
+ public:
+ int maximumCostSubstring(const string &s, const string &chars, const vector<int> &vals) {
+ static int cost[27];
+
+ for (int i = 1; i <= 26; i++)
+ cost[i] = i;
+ for (int i = 0; i < size(vals); i++)
+ cost[chars[i] & 0x1F] = vals[i];
+
+ int res = 0, crnt = 0;
+ for (int i = 0; i < size(s); i++) {
+ crnt = max(0, crnt + cost[s[i] & 0x1F]);
+ res = max(res, crnt);
+ }
+
+ return res;
+ }
+};
diff --git a/README.md b/README.md
@@ -1063,6 +1063,7 @@ for solving problems.
| 2579 | Medium | [Count Total Number of Colored Cells](Problems/2579.cpp) |
| 2592 | Medium | [Maximize Greatness of an Array](Problems/2592.cpp) |
| 2596 | Medium | [Check Knight Tour Configuration](Problems/2596.cpp) |
+| 2606 | Medium | [Find the Substring With Maximum Cost](Problems/2606.cpp) |
| 2610 | Medium | [Convert an Array Into a 2D Array With Conditions](Problems/2610.cpp) |
| 2616 | Medium | [Minimize the Maximum Difference of Pairs](Problems/2616.cpp) |
| 2620 | Easy | [Counter](Problems/2620.js) |