Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Solution:
- def minOperations(self, boxes: str) -> List[int]:
- a = [0]*len(boxes)
- count1, cost1, count2, cost2, n = 0, 0, 0, 0, len(boxes)
- for i in range(1, n):
- if boxes[i-1] == '1': count1 += 1
- cost1 += count1
- a[i] = cost1
- for j in range(n-2, -1, -1):
- if boxes[j+1] == '1': count2 += 1
- cost2 += count2
- a[j] += cost2
- return a
Advertisement
Add Comment
Please, Sign In to add comment