Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Solution:
- def minimumCost(self, cost: List[int]) -> int:
- cost.sort(reverse=True)
- n = len(cost)
- cost.append(0)
- res = 0
- i = 0
- while i < n:
- res += cost[i] + cost[i+1]
- i += 3
- return res
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement