You are given a 0-indexed integer array
nums
of sizen
representing the cost of collecting different chocolates. Each chocolate is of a different type, and originally, the chocolate atith
index is ofith
type.In one operation, you can do the following with an incurred cost of
x
:
- Simultaneously change the chocolate of
ith
type to (i + 1)th
type for all indexesi
where0 <= 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 { |