Skip to content

Commit 66215ec

Browse files
Shubhtechyminati
authored andcommitted
python(new sol): leetcode 1578 sol
* add leetcode question number 1578 python 3 solution
1 parent a02cf60 commit 66215ec

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

‎leetcode-1578.py‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
class Solution:
2+
def minCost(self, colors: str, cost: List[int]) -> int:
3+
4+
res = 0
5+
for i in range(1, len(colors)):
6+
if colors[i] == colors[i-1]:
7+
res += min(cost[i], cost[i-1])
8+
cost[i] = max(cost[i], cost[i-1])
9+
10+
return res

0 commit comments

Comments
 (0)