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; } };