You are given a 0-indexed integer array
numsof sizenrepresenting the cost of collecting different chocolates. Each chocolate is of a different type, and originally, the chocolate atithindex is ofithtype.In one operation, you can do the following with an incurred cost of
x:
- Simultaneously change the chocolate of
ithtype to (i + 1)thtype for all indexesiwhere0 <= i < n - 1. Wheni == n - 1, that chocolate will be changed to type of the chocolate at index0.Return the minimum cost to collect chocolates of all types, given that you can perform as many operations as you would like.
1 | class Solution { |