Skip to content

Commit a4e23c8

Browse files
authored
Create Minimum Time to Make Rope Colorful.cpp
1 parent c6cdbff commit a4e23c8

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
//problem statement https://leetcode.com/problems/minimum-time-to-make-rope-colorful/
2+
class Solution {
3+
public:
4+
int minCost(string c, vector<int>& nT) {
5+
int n=c.size();
6+
int sum=0;
7+
int mx=nT[0];
8+
for(int i=1;i<=n;i++){
9+
if(c[i]==c[i-1]){
10+
sum+=min(nT[i-1],nT[i]);
11+
nT[i]=max(nT[i],nT[i-1]);
12+
}
13+
}
14+
return sum;
15+
}
16+
};

0 commit comments

Comments
 (0)