原题题目
代码实现(首刷自解)
class Solution {
public:int minCost(string s, vector<int>& cost) {
int ret = 0;for(int i=1;i<s.size();++i){
if(s[i] == s[i-1]){
ret += min(cost[i],cost[i-1]);cost[i] = max(cost[i],cost[i-1]);}}return ret;}
};
class Solution {
public:int minCost(string s, vector<int>& cost) {
int ret = 0;for(int i=1;i<s.size();++i){
if(s[i] == s[i-1]){
ret += min(cost[i],cost[i-1]);cost[i] = max(cost[i],cost[i-1]);}}return ret;}
};